diff options
author | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:34:59 +0100 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:34:59 +0100 |
commit | 339ed7f63798fb5ccab05fa7fb9d0d95743c9c89 (patch) | |
tree | 214819f601b69bfd32507ca59047dd4d68ed5632 /zen/file_traverser.cpp | |
parent | 7.9 (diff) | |
download | FreeFileSync-339ed7f63798fb5ccab05fa7fb9d0d95743c9c89.tar.gz FreeFileSync-339ed7f63798fb5ccab05fa7fb9d0d95743c9c89.tar.bz2 FreeFileSync-339ed7f63798fb5ccab05fa7fb9d0d95743c9c89.zip |
8.0
Diffstat (limited to 'zen/file_traverser.cpp')
-rw-r--r-- | zen/file_traverser.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/zen/file_traverser.cpp b/zen/file_traverser.cpp index 7fd6c596..aa39e508 100644 --- a/zen/file_traverser.cpp +++ b/zen/file_traverser.cpp @@ -102,9 +102,6 @@ void zen::traverseFolder(const Zstring& dirPath, entryp = malloc(len); */ const size_t nameMax = std::max<long>(::pathconf(dirPath.c_str(), _PC_NAME_MAX), 10000); //::pathconf may return long(-1) std::vector<char> buffer(offsetof(struct ::dirent, d_name) + nameMax + 1); -#ifdef ZEN_MAC - std::vector<char> bufferUtfDecomposed; -#endif DIR* folder = ::opendir(dirPath.c_str()); //directory must NOT end with path separator, except "/" if (!folder) @@ -131,26 +128,21 @@ void zen::traverseFolder(const Zstring& dirPath, (itemNameRaw[1] == 0 || (itemNameRaw[1] == '.' && itemNameRaw[2] == 0))) continue; #ifdef ZEN_MAC - //some file system abstraction layers fail to properly return decomposed UTF8: http://developer.apple.com/library/mac/#qa/qa1173/_index.html - //so we need to do it ourselves; perf: ~600 ns per conversion - //note: it's not sufficient to apply this in z_impl::compareFilenamesNoCase: if UTF8 forms differ, FFS assumes a rename in case sensitivity and - // will try to propagate the rename => this won't work if target drive reports a particular UTF8 form only! - if (CFStringRef cfStr = osx::createCFString(itemNameRaw)) + //see native_traverser_impl.h: + Zstring itemName; + try { - ZEN_ON_SCOPE_EXIT(::CFRelease(cfStr)); - - CFIndex lenMax = ::CFStringGetMaximumSizeOfFileSystemRepresentation(cfStr); //"could be much larger than the actual space required" => don't store in Zstring - if (lenMax > 0) - { - bufferUtfDecomposed.resize(lenMax); - if (::CFStringGetFileSystemRepresentation(cfStr, &bufferUtfDecomposed[0], lenMax)) //get decomposed UTF form (verified!) despite ambiguous documentation - itemNameRaw = &bufferUtfDecomposed[0]; - } + itemName = osx::convertToPrecomposedUtf(itemNameRaw); //throw SysError } - //const char* sampleDecomposed = "\x6f\xcc\x81.txt"; - //const char* samplePrecomposed = "\xc3\xb3.txt"; -#endif + catch (const SysError& e) //failure is not an item-level error since wo don't have the proper decomposed name!!! + { + throw FileError(replaceCpy(_("Cannot enumerate directory %x."), L"%x", fmtPath(dirPath)), + L"Failed to generate precomposed file name: " + fmtPath(itemNameRaw) + L"\n" + e.toString()); //too obscure to warrant translation + } + const Zstring& itemPath = appendSeparator(dirPath) + itemName; +#else const Zstring& itemPath = appendSeparator(dirPath) + itemNameRaw; +#endif struct ::stat statData = {}; try |