commit d0911fc9d0d764bf0937cbf58ebae9a3475def4e
parent 4cb302522651af034834c78e77d6df238eb51b7f
Author: cfillion <cfillion@users.noreply.github.com>
Date: Wed, 15 Jan 2020 12:46:13 -0500
fix creating directories with paths longer than 248 characters on Windows
While the limit for file paths is 260 characters (MAX_PATH), the limit for folders is 248 (MAX_PATH - enough room for a 8.1 filename).
Diffstat:
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/path.cpp b/src/path.cpp
@@ -200,7 +200,7 @@ std::string Path::join(const bool nativeSeparator) const
}
#ifdef _WIN32
- if(test(Absolute) && path.size() > MAX_PATH) {
+ if(test(Absolute) && path.size() >= MAX_PATH - (8+1+3)) {
path.insert(0, "\\\\?\\");
if(test(UNC))
diff --git a/test/path.cpp b/test/path.cpp
@@ -213,7 +213,7 @@ TEST_CASE("append absolute path to empty path", M) {
TEST_CASE("extended absolute paths", M) {
#ifdef _WIN32
Path abs("C:\\");
- abs.append(std::string(260, 'a'));
+ abs.append(std::string(245, 'a'));
CHECK(abs.test(Path::Absolute));
REQUIRE_THAT(abs.join(), StartsWith("\\\\?\\"));