diff options
Diffstat (limited to 'zen/long_path_prefix.h')
-rw-r--r-- | zen/long_path_prefix.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/zen/long_path_prefix.h b/zen/long_path_prefix.h index 80b5453e..c3d705e2 100644 --- a/zen/long_path_prefix.h +++ b/zen/long_path_prefix.h @@ -51,20 +51,22 @@ Zstring removeLongPathPrefix(const Zstring& path); //throw() const Zstring LONG_PATH_PREFIX = L"\\\\?\\"; const Zstring LONG_PATH_PREFIX_UNC = L"\\\\?\\UNC"; -template <size_t max_path> inline +template <size_t maxPath> inline Zstring applyLongPathPrefixImpl(const Zstring& path) { assert(!path.empty()); //nicely check almost all WinAPI accesses! assert(!zen::isWhiteSpace(path[0])); - if (path.length() >= max_path && //maximum allowed path length without prefix is (MAX_PATH - 1) - !zen::startsWith(path, LONG_PATH_PREFIX)) - { - if (zen::startsWith(path, L"\\\\")) //UNC-name, e.g. \\zenju-pc\Users - return LONG_PATH_PREFIX_UNC + zen::afterFirst(path, L'\\'); //convert to \\?\UNC\zenju-pc\Users - else - return LONG_PATH_PREFIX + path; //prepend \\?\ prefix - } + if (path.length() >= maxPath || //maximum allowed path length without prefix is (MAX_PATH - 1) + endsWith(path, L' ') || //by default all Win32 APIs trim trailing spaces and period, unless long path prefix is supplied! + endsWith(path, L'.')) // + if (!startsWith(path, LONG_PATH_PREFIX)) + { + if (startsWith(path, L"\\\\")) //UNC-name, e.g. \\zenju-pc\Users + return LONG_PATH_PREFIX_UNC + afterFirst(path, L'\\'); //convert to \\?\UNC\zenju-pc\Users + else + return LONG_PATH_PREFIX + path; //prepend \\?\ prefix + } return path; //fallback } |