X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=Src%2FDirTravel.cpp;h=bc7ba5a28b1b8a212c364d7bb4d6f33042f89a87;hb=f1134ec14b6e24b3fa8bf385786a20b6ac081bc9;hp=27d6463dc1c45726fc1c2943a3ca0af119e336a8;hpb=4580a0c7cf60ba908d9b21a754bdc2d59c8bd9c8;p=winmerge-jp%2Fwinmerge-jp.git diff --git a/Src/DirTravel.cpp b/Src/DirTravel.cpp index 27d6463dc..bc7ba5a28 100644 --- a/Src/DirTravel.cpp +++ b/Src/DirTravel.cpp @@ -5,18 +5,20 @@ * */ +#include "pch.h" #include "DirTravel.h" #include -#include #include #include #include #include -#include +#include "TFile.h" #include "UnicodeString.h" #include "DirItem.h" #include "unicoder.h" #include "paths.h" +#include "Win_VersionHelper.h" +#include "DebugNew.h" using Poco::DirectoryIterator; using Poco::Timestamp; @@ -35,16 +37,16 @@ void LoadAndSortFiles(const String& sDir, DirItemArray * dirs, DirItemArray * fi } /** - * @brief Find files and subfolders from given folder. - * This function saves all files and subfolders in given folder to arrays. + * @brief Find file and sub-folder names from given folder. + * This function saves all file and sub-folder names in given folder to arrays. * We use 64-bit version of stat() to get times since find doesn't return * valid times for very old files (around year 1970). Even stat() seems to * give negative time values but we can live with that. Those around 1970 - * times can happen when file is created so that it doesn't get valid - * creation or modificatio dates. + * times can happen when file is created so that it doesn't get valid + * creation or modification dates. * @param [in] sDir Base folder for files and subfolders. - * @param [in, out] dirs Array where subfolders are stored. - * @param [in, out] files Array where files are stored. + * @param [in, out] dirs Array where subfolder names are stored. + * @param [in, out] files Array where file names are stored. */ static void LoadFiles(const String& sDir, DirItemArray * dirs, DirItemArray * files) { @@ -69,11 +71,7 @@ static void LoadFiles(const String& sDir, DirItemArray * dirs, DirItemArray * fi ent.size = it->getSize(); ent.path = dir; ent.filename = ucr::toTString(it.name()); -#ifdef _WIN32 - ent.flags.attributes = GetFileAttributes(ucr::toTString(it.name()).c_str());; -#else -#endif - + ent.flags.attributes = GetFileAttributes(ucr::toTString(it.name()).c_str()); (bIsDirectory ? dirs : files)->push_back(ent); } @@ -82,15 +80,10 @@ static void LoadFiles(const String& sDir, DirItemArray * dirs, DirItemArray * fi WIN32_FIND_DATA ff; HANDLE h; - OSVERSIONINFO vi; - vi.dwOSVersionInfoSize = sizeof(vi); - GetVersionEx(&vi); - - poco_assert(wcsncmp(sPattern.c_str(), L"\\\\?\\", 4) != 0); // Prefix better not be there yet - if (vi.dwMajorVersion * 10 + vi.dwMinorVersion >= 61) - h = FindFirstFileEx((L"\\\\?\\" + sPattern).c_str(), FindExInfoBasic, &ff, FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH); + if (IsWin7_OrGreater()) // (also 'Windows Server 2008 R2' and greater) for FindExInfoBasic and FIND_FIRST_EX_LARGE_FETCH + h = FindFirstFileEx(TFile(sPattern).wpath().c_str(), FindExInfoBasic, &ff, FindExSearchNameMatch, nullptr, FIND_FIRST_EX_LARGE_FETCH); else - h = FindFirstFile((L"\\\\?\\" + sPattern).c_str(), &ff); + h = FindFirstFile(TFile(sPattern).wpath().c_str(), &ff); if (h != INVALID_HANDLE_VALUE) { do