diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-23 17:57:18 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-23 17:57:18 -0700 |
| commit | 1cd1f6a46bdd2eb8a27dabb8e8eb69d36694d6d6 (patch) | |
| tree | 09dbdbe6b0d31b719fe56b04a47571d6721bf327 /toolsrc/src/vcpkg_Files.cpp | |
| parent | c7a7d062a750bce13a9db3fa8af5018d38554565 (diff) | |
| download | vcpkg-1cd1f6a46bdd2eb8a27dabb8e8eb69d36694d6d6.tar.gz vcpkg-1cd1f6a46bdd2eb8a27dabb8e8eb69d36694d6d6.zip | |
Add Files::has_invalid_chars_for_filesystem()
Diffstat (limited to 'toolsrc/src/vcpkg_Files.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg_Files.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp index ef330ea27..611aa7450 100644 --- a/toolsrc/src/vcpkg_Files.cpp +++ b/toolsrc/src/vcpkg_Files.cpp @@ -1,16 +1,24 @@ #include "vcpkg_Files.h" #include <fstream> #include <filesystem> +#include <regex> namespace fs = std::tr2::sys; namespace vcpkg {namespace Files { + static const std::regex FILESYSTEM_INVALID_CHARACTERS_REGEX = std::regex(R"([\/:*?"<>|])"); + void check_is_directory(const fs::path& dirpath) { Checks::check_throw(fs::is_directory(dirpath), "The path %s is not a directory", dirpath.string()); } + bool has_invalid_chars_for_filesystem(const std::string s) + { + return std::regex_search(s, FILESYSTEM_INVALID_CHARACTERS_REGEX); + } + expected<std::string> get_contents(const fs::path& file_path) noexcept { std::fstream file_stream(file_path, std::ios_base::in | std::ios_base::binary); |
