Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/vcpkg/base/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ namespace vcpkg

virtual bool last_write_time(DiagnosticContext& context, const Path& target, int64_t new_time) const = 0;

virtual bool set_executable(DiagnosticContext& context, const Path& target) const = 0;

using ReadOnlyFilesystem::current_path;
virtual void current_path(const Path& new_current_path, std::error_code&) const = 0;
void current_path(const Path& new_current_path, LineInfo li) const;
Expand Down
38 changes: 38 additions & 0 deletions src/vcpkg/base/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4051,6 +4051,31 @@ namespace vcpkg
#endif // ^^^ !_WIN32
}

virtual bool set_executable(DiagnosticContext& context, const Path& target) const override
{
#if defined(_WIN32)
// On Windows, executability is determined by file extension, not permissions.
(void)context;
(void)target;
return true;
#else // ^^^ _WIN32 // !_WIN32 vvv
if (::chmod(target.c_str(), 0755) != 0)
{
auto local_errno = errno;
context.report(
DiagnosticLine{DiagKind::Error,
target,
msg::format(msgSystemApiErrorMessage,
msg::system_api = "chmod",
msg::exit_code = local_errno,
msg::error_msg = std::generic_category().message(local_errno))});
return false;
}

return true;
#endif // ^^^ !_WIN32
}

virtual void write_contents(const Path& file_path, StringView data, std::error_code& ec) const override
{
StatsTimer t(g_us_filesystem_stats);
Expand Down Expand Up @@ -4494,6 +4519,19 @@ namespace vcpkg
return false;
}

bool set_executable(DiagnosticContext& context, const Path&) const override
{
context.report_system_error("set_executable",
#if defined(_WIN32)
ERROR_NOT_SUPPORTED
#else
ENOTSUP
#endif
);

return false;
}

void current_path(const Path&, std::error_code& ec) const override { assign_not_supported(ec); }

std::unique_ptr<IExclusiveFileLock> take_exclusive_file_lock(DiagnosticContext& context,
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ namespace vcpkg
return nullopt;
}

fs.set_executable(context, exe_path);
return exe_path;
}

Expand Down
Loading