reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 25bb564c6ab860d43ff8ca27b8d5b15cfc0e4c24
parent 02a89c5f8db2694187c2059a93f3d739a4ad47d3
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue,  3 Oct 2017 02:42:02 -0700

path: allow paths longer than 260 characters on Windows [p=1861355]

However REAPER always writes an absolute paths to reaper-kb.ini (breaking script
portability) when the path starts with the extended-length prefix (\\?\).

Diffstat:
Msrc/path.cpp | 6++++++
Mtest/path.cpp | 20++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/path.cpp b/src/path.cpp @@ -26,6 +26,7 @@ using namespace std; #ifndef _WIN32 static constexpr char SEPARATOR = '/'; #else +#include <windows.h> // MAX_PATH static constexpr char SEPARATOR = '\\'; #endif @@ -167,6 +168,11 @@ string Path::join(const char sep) const path += part; } +#ifdef _WIN32 + if(m_absolute && path.size() > MAX_PATH) + path.insert(0, "\\\\?\\"); +#endif + return path; } diff --git a/test/path.cpp b/test/path.cpp @@ -2,6 +2,8 @@ #include <path.hpp> +using Catch::Matchers::StartsWith; + using namespace std; static const char *M = "[path]"; @@ -177,6 +179,24 @@ TEST_CASE("append absolute path to empty path", M) { REQUIRE(path.absolute()); } +TEST_CASE("extended absolute paths", M) { +#ifdef _WIN32 + Path abs("C:\\"); + abs.append(string(260, 'a')); + + CHECK(abs.absolute()); + REQUIRE_THAT(abs.join(), StartsWith("\\\\?\\")); + + const Path path(string(500, 'a')); + CHECK_FALSE(path.absolute()); +#else + Path path("/hello"); + path.append(string(260, 'a')); +#endif + + REQUIRE_THAT(path.join(), !StartsWith("\\\\?\\")); +} + #ifndef _WIN32 TEST_CASE("compare absolute to relative path (unix)", M) { REQUIRE(Path("/a/b") != Path("a/b"));