From 110fc5dee14fc7988f631a158e50d283446aba7a Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:24:09 +0200 Subject: 5.15 --- zen/long_path_prefix.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'zen/long_path_prefix.h') 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 inline +template 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 } -- cgit