diff options
author | B. Stack <bgstack15@gmail.com> | 2022-09-07 18:49:36 +0000 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-09-07 18:49:36 +0000 |
commit | 62bcefb8b809a32c6d26ab04ca686578bba5567a (patch) | |
tree | fbc1dea58a6b28f1af4a9e9b2bc8e3e1d23b2103 /zen/file_path.cpp | |
parent | Merge branch 'b11.23' into 'master' (diff) | |
parent | add upstream 11.24 (diff) | |
download | FreeFileSync-62bcefb8b809a32c6d26ab04ca686578bba5567a.tar.gz FreeFileSync-62bcefb8b809a32c6d26ab04ca686578bba5567a.tar.bz2 FreeFileSync-62bcefb8b809a32c6d26ab04ca686578bba5567a.zip |
Merge branch 'b11.24' into 'master'11.24
add upstream 11.24
See merge request opensource-tracking/FreeFileSync!47
Diffstat (limited to 'zen/file_path.cpp')
-rw-r--r-- | zen/file_path.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/zen/file_path.cpp b/zen/file_path.cpp index 716dd8de..f5c207f3 100644 --- a/zen/file_path.cpp +++ b/zen/file_path.cpp @@ -13,11 +13,12 @@ std::optional<PathComponents> zen::parsePathComponents(const Zstring& itemPath) { auto doParse = [&](int sepCountVolumeRoot, bool rootWithSep) -> std::optional<PathComponents> { + assert(sepCountVolumeRoot > 0); const Zstring itemPathPf = appendSeparator(itemPath); //simplify analysis of root without separator, e.g. \\server-name\share - int sepCount = 0; + for (auto it = itemPathPf.begin(); it != itemPathPf.end(); ++it) if (*it == FILE_NAME_SEPARATOR) - if (++sepCount == sepCountVolumeRoot) + if (--sepCountVolumeRoot == 0) { Zstring rootPath(itemPathPf.begin(), rootWithSep ? it + 1 : it); @@ -89,7 +90,7 @@ bool zen::isValidRelPath(const Zstring& relPath) if constexpr (FILE_NAME_SEPARATOR != Zstr('\\')) if (contains(relPath, Zstr('\\'))) return false; const Zchar doubleSep[] = {FILE_NAME_SEPARATOR, FILE_NAME_SEPARATOR, 0}; - return !startsWith(relPath, FILE_NAME_SEPARATOR)&& !endsWith(relPath, FILE_NAME_SEPARATOR)&& + return !startsWith(relPath, FILE_NAME_SEPARATOR) && !endsWith(relPath, FILE_NAME_SEPARATOR) && !contains(relPath, doubleSep); } |