aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/util.cpp
diff options
context:
space:
mode:
authorCurtis J Bezault <curtbezault@gmail.com>2019-08-09 11:59:32 -0400
committerGitHub <noreply@github.com>2019-08-09 11:59:32 -0400
commitc4f1a91ef245ed3e44ea11f13040a77453126165 (patch)
tree3e6c99d970fe8a5fcd1551bbcbf9fde4f0b0a3a4 /toolsrc/src/vcpkg-test/util.cpp
parent9da7c5c99ee42e382895dbd0dafdd29beaa61075 (diff)
parent743e168ef5c7705e44d1d5cab5b9cca22328345e (diff)
downloadvcpkg-c4f1a91ef245ed3e44ea11f13040a77453126165.tar.gz
vcpkg-c4f1a91ef245ed3e44ea11f13040a77453126165.zip
Merge branch 'master' into external_file_abi
Diffstat (limited to 'toolsrc/src/vcpkg-test/util.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/util.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp
index a80ab36a0..384954b4e 100644
--- a/toolsrc/src/vcpkg-test/util.cpp
+++ b/toolsrc/src/vcpkg-test/util.cpp
@@ -74,14 +74,15 @@ 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 defined(_WIN32)
- if (!__cpp_lib_filesystem)
- {
- return false;
- }
-
+#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE
+ return AllowSymlinks::No;
+#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
+ return AllowSymlinks::Yes;
+#elif !defined(_WIN32) // FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD
+ return AllowSymlinks::Yes;
+#else
HKEY key;
bool allow_symlinks = true;
@@ -96,13 +97,14 @@ namespace vcpkg::Test
if (status == ERROR_SUCCESS) RegCloseKey(key);
- return allow_symlinks;
-#else
- return true;
+ return allow_symlinks ? AllowSymlinks::Yes : AllowSymlinks::No;
#endif
}
+ const static AllowSymlinks CAN_CREATE_SYMLINKS = internal_can_create_symlinks();
+
+ AllowSymlinks can_create_symlinks() noexcept { return CAN_CREATE_SYMLINKS; }
- static fs::path internal_temporary_directory()
+ static fs::path internal_base_temporary_directory()
{
#if defined(_WIN32)
wchar_t* tmp = static_cast<wchar_t*>(std::calloc(32'767, 2));
@@ -122,18 +124,19 @@ 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();
-#if FILESYSTEM_SYMLINK == FILSYSTEM_SYMLINK_NONE
- constexpr inline char no_filesystem_message[] =
+ const fs::path& base_temporary_directory() noexcept { return BASE_TEMPORARY_DIRECTORY; }
+
+#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE
+ constexpr char no_filesystem_message[] =
"<filesystem> doesn't exist; on windows, we don't attempt to use the win32 calls to create symlinks";
#endif
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();
@@ -157,12 +160,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);
}
else
{