summaryrefslogtreecommitdiff
path: root/zen/long_path_prefix.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:24:09 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:24:09 +0200
commit110fc5dee14fc7988f631a158e50d283446aba7a (patch)
tree7c19dfd3bdb8c4636409ec80a38c70499ac006db /zen/long_path_prefix.h
parent5.14 (diff)
downloadFreeFileSync-110fc5dee14fc7988f631a158e50d283446aba7a.tar.gz
FreeFileSync-110fc5dee14fc7988f631a158e50d283446aba7a.tar.bz2
FreeFileSync-110fc5dee14fc7988f631a158e50d283446aba7a.zip
5.15
Diffstat (limited to 'zen/long_path_prefix.h')
-rw-r--r--zen/long_path_prefix.h20
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
}
bgstack15