diff options
| author | Alexander Neumann <alexander.neumann@hamburg.de> | 2019-08-12 09:28:24 +0200 |
|---|---|---|
| committer | Alexander Neumann <alexander.neumann@hamburg.de> | 2019-08-12 09:28:24 +0200 |
| commit | c4231c51e47221345525ce68b65b28ab905087e2 (patch) | |
| tree | 3f387da83563b5aeaaad91b3fec05580236d057e /toolsrc/src/vcpkg-test/util.cpp | |
| parent | 5899cd1d25c134f8a30476f4939ab57952c59815 (diff) | |
| parent | fffcd0a5ae21d0b7ae0c8cdbd7bd1210f5a29031 (diff) | |
| download | vcpkg-c4231c51e47221345525ce68b65b28ab905087e2.tar.gz vcpkg-c4231c51e47221345525ce68b65b28ab905087e2.zip | |
Merge remote-tracking branch 'upstream/master' into path_separator
Diffstat (limited to 'toolsrc/src/vcpkg-test/util.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg-test/util.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp index 5359b0fad..a2343c21b 100644 --- a/toolsrc/src/vcpkg-test/util.cpp +++ b/toolsrc/src/vcpkg-test/util.cpp @@ -74,14 +74,14 @@ namespace vcpkg::Test return m_ret.value_or_exit(VCPKG_LINE_INFO); } - static bool system_allows_symlinks() + static AllowSymlinks internal_can_create_symlinks() noexcept { #if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE - return false; + return AllowSymlinks::No; #elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX - return true; + return AllowSymlinks::Yes; #elif !defined(_WIN32) // FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD - return true; + return AllowSymlinks::Yes; #else HKEY key; bool allow_symlinks = true; @@ -97,11 +97,14 @@ namespace vcpkg::Test if (status == ERROR_SUCCESS) RegCloseKey(key); - return allow_symlinks; + return allow_symlinks ? AllowSymlinks::Yes : AllowSymlinks::No; #endif } + const static AllowSymlinks CAN_CREATE_SYMLINKS = internal_can_create_symlinks(); - static fs::path internal_temporary_directory() + AllowSymlinks can_create_symlinks() noexcept { return CAN_CREATE_SYMLINKS; } + + static fs::path internal_base_temporary_directory() { #if defined(_WIN32) wchar_t* tmp = static_cast<wchar_t*>(std::calloc(32'767, 2)); @@ -121,8 +124,9 @@ namespace vcpkg::Test #endif } - const bool SYMLINKS_ALLOWED = system_allows_symlinks(); - const fs::path TEMPORARY_DIRECTORY = internal_temporary_directory(); + const static fs::path BASE_TEMPORARY_DIRECTORY = internal_base_temporary_directory(); + + const fs::path& base_temporary_directory() noexcept { return BASE_TEMPORARY_DIRECTORY; } #if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE constexpr char no_filesystem_message[] = @@ -132,12 +136,12 @@ namespace vcpkg::Test void create_symlink(const fs::path& target, const fs::path& file, std::error_code& ec) { #if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD - if (SYMLINKS_ALLOWED) + if (can_create_symlinks()) { std::filesystem::path targetp = target.native(); std::filesystem::path filep = file.native(); - std::filesystem::create_symlink(targetp, filep); + std::filesystem::create_symlink(targetp, filep, ec); } else { @@ -149,6 +153,7 @@ namespace vcpkg::Test ec.assign(errno, std::system_category()); } #else + static_cast<void>(ec); vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message); #endif } @@ -156,12 +161,12 @@ namespace vcpkg::Test void create_directory_symlink(const fs::path& target, const fs::path& file, std::error_code& ec) { #if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD - if (SYMLINKS_ALLOWED) + if (can_create_symlinks()) { std::filesystem::path targetp = target.native(); std::filesystem::path filep = file.native(); - std::filesystem::create_symlink(targetp, filep); + std::filesystem::create_directory_symlink(targetp, filep, ec); } else { @@ -170,6 +175,7 @@ namespace vcpkg::Test #elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX ::vcpkg::Test::create_symlink(target, file, ec); #else + static_cast<void>(ec); vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message); #endif } |
