Skip to content

Commit 4efd262

Browse files
Tom94wjakob
authored andcommitted
Compilation fixes (#24)
* Support long file names under Windows * Fix unix compilation * Fix compilation error on Windows
1 parent d918328 commit 4efd262

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

filesystem/path.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#pragma once
1111

1212
#include "fwd.h"
13+
#include <algorithm>
1314
#include <string>
1415
#include <vector>
1516
#include <stdexcept>
@@ -197,7 +198,7 @@ class path {
197198
// Windows requires a \\?\ prefix to handle paths longer than MAX_PATH
198199
// (including their null character). NOTE: relative paths >MAX_PATH are
199200
// not supported at all in Windows.
200-
if (length > MAX_PATH)
201+
if (length > MAX_PATH_WINDOWS_LEGACY)
201202
oss << "\\\\?\\";
202203
}
203204
}
@@ -350,6 +351,7 @@ class path {
350351
#if defined(_WIN32)
351352
static const size_t MAX_PATH_WINDOWS = 32767;
352353
#endif
354+
static const size_t MAX_PATH_WINDOWS_LEGACY = 260;
353355
path_type m_type;
354356
std::vector<std::string> m_path;
355357
bool m_absolute;
@@ -365,7 +367,7 @@ inline bool create_directory(const path& p) {
365367

366368
inline bool create_directories(const path& p) {
367369
#if defined(_WIN32)
368-
return SHCreateDirectory(nullptr, make_absolute().wstr().c_str()) == ERROR_SUCCESS;
370+
return SHCreateDirectory(nullptr, p.make_absolute().wstr().c_str()) == ERROR_SUCCESS;
369371
#else
370372
if (create_directory(p.str().c_str()))
371373
return true;

0 commit comments

Comments
 (0)