diff options
| author | Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> | 2020-08-18 09:23:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-18 09:23:01 -0700 |
| commit | 0bb8780a60e67320a966421e2923595fa57cbf22 (patch) | |
| tree | 494b4a99592f5bd17195397ae3acd37d38fa9dc6 /toolsrc/include | |
| parent | d6285bc24b2e48da2f5e057fc759aff7c2b3b0af (diff) | |
| download | vcpkg-0bb8780a60e67320a966421e2923595fa57cbf22.tar.gz vcpkg-0bb8780a60e67320a966421e2923595fa57cbf22.zip | |
[vcpkg] Use std::filesystem when Visual Studio is greater than 2015 (#12774)
Co-authored-by: Nicole Mazzuca <mazzucan@outlook.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/pch.h | 9 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/files.h | 31 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/system.process.h | 2 |
3 files changed, 31 insertions, 11 deletions
diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h index f92792411..c8ca1ea7c 100644 --- a/toolsrc/include/pch.h +++ b/toolsrc/include/pch.h @@ -2,6 +2,7 @@ #include <vcpkg/base/system_headers.h> +#include <vcpkg/base/files.h> #include <vcpkg/base/pragmas.h> #if defined(_WIN32) @@ -23,14 +24,6 @@ #include <cctype> #include <chrono> #include <codecvt> - -#if VCPKG_USE_STD_FILESYSTEM -#include <filesystem> -#else -#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING -#include <experimental/filesystem> -#endif - #include <fstream> #include <functional> #include <iomanip> diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index a202bfdef..e0a555024 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -2,11 +2,17 @@ #include <vcpkg/base/expected.h> #include <vcpkg/base/ignore_errors.h> +#include <vcpkg/base/pragmas.h> + +#include <string.h> + +#if !defined(VCPKG_USE_STD_FILESYSTEM) +#error The build system must set VCPKG_USE_STD_FILESYSTEM. +#endif // !defined(VCPKG_USE_STD_FILESYSTEM) #if VCPKG_USE_STD_FILESYSTEM #include <filesystem> #else -#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include <experimental/filesystem> #endif @@ -22,7 +28,28 @@ namespace fs using stdfs::directory_iterator; using stdfs::path; using stdfs::perms; - using stdfs::u8path; + + path u8path(vcpkg::StringView s); + inline path u8path(const char* first, const char* last) { return u8path(vcpkg::StringView{first, last}); } + inline path u8path(const char* s) { return u8path(vcpkg::StringView{s, s + ::strlen(s)}); } + +#if defined(_MSC_VER) + inline path u8path(std::string::const_iterator first, std::string::const_iterator last) + { + if (first == last) + { + return path{}; + } + else + { + auto firstp = &*first; + return u8path(vcpkg::StringView{firstp, firstp + (last - first)}); + } + } +#endif + + std::string u8string(const path& p); + std::string generic_u8string(const path& p); #if defined(_WIN32) enum class file_type diff --git a/toolsrc/include/vcpkg/base/system.process.h b/toolsrc/include/vcpkg/base/system.process.h index b9184c05c..4bbcba717 100644 --- a/toolsrc/include/vcpkg/base/system.process.h +++ b/toolsrc/include/vcpkg/base/system.process.h @@ -25,7 +25,7 @@ namespace vcpkg::System struct CmdLineBuilder { - CmdLineBuilder& path_arg(const fs::path& p) { return string_arg(p.u8string()); } + CmdLineBuilder& path_arg(const fs::path& p) { return string_arg(fs::u8string(p)); } CmdLineBuilder& string_arg(StringView s); CmdLineBuilder& ampersand() { |
