aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/FileFind.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/Windows/FileFind.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/CPP/Windows/FileFind.cpp b/CPP/Windows/FileFind.cpp
index c655759..c562a90 100644
--- a/CPP/Windows/FileFind.cpp
+++ b/CPP/Windows/FileFind.cpp
@@ -39,10 +39,10 @@ typedef struct
39 WCHAR cStreamName[MAX_PATH + 36]; 39 WCHAR cStreamName[MAX_PATH + 36];
40} MY_WIN32_FIND_STREAM_DATA, *MY_PWIN32_FIND_STREAM_DATA; 40} MY_WIN32_FIND_STREAM_DATA, *MY_PWIN32_FIND_STREAM_DATA;
41 41
42typedef HANDLE (WINAPI *FindFirstStreamW_Ptr)(LPCWSTR fileName, MY_STREAM_INFO_LEVELS infoLevel, 42typedef HANDLE (WINAPI *Func_FindFirstStreamW)(LPCWSTR fileName, MY_STREAM_INFO_LEVELS infoLevel,
43 LPVOID findStreamData, DWORD flags); 43 LPVOID findStreamData, DWORD flags);
44 44
45typedef BOOL (APIENTRY *FindNextStreamW_Ptr)(HANDLE findStream, LPVOID findStreamData); 45typedef BOOL (APIENTRY *Func_FindNextStreamW)(HANDLE findStream, LPVOID findStreamData);
46 46
47EXTERN_C_END 47EXTERN_C_END
48 48
@@ -54,7 +54,7 @@ namespace NFile {
54 54
55 55
56#ifdef _WIN32 56#ifdef _WIN32
57#ifdef SUPPORT_DEVICE_FILE 57#ifdef Z7_DEVICE_FILE
58namespace NSystem 58namespace NSystem
59{ 59{
60bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize); 60bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize);
@@ -128,7 +128,7 @@ bool CFileInfo::IsDots() const throw()
128 128
129static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATAW &fd, CFileInfo &fi) 129static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATAW &fd, CFileInfo &fi)
130{ 130{
131 WIN_FD_TO_MY_FI(fi, fd); 131 WIN_FD_TO_MY_FI(fi, fd)
132 fi.Name = us2fs(fd.cFileName); 132 fi.Name = us2fs(fd.cFileName);
133 #if defined(_WIN32) && !defined(UNDER_CE) 133 #if defined(_WIN32) && !defined(UNDER_CE)
134 // fi.ShortName = us2fs(fd.cAlternateFileName); 134 // fi.ShortName = us2fs(fd.cAlternateFileName);
@@ -138,7 +138,7 @@ static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATAW &fd, CFil
138#ifndef _UNICODE 138#ifndef _UNICODE
139static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATA &fd, CFileInfo &fi) 139static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATA &fd, CFileInfo &fi)
140{ 140{
141 WIN_FD_TO_MY_FI(fi, fd); 141 WIN_FD_TO_MY_FI(fi, fd)
142 fi.Name = fas2fs(fd.cFileName); 142 fi.Name = fas2fs(fd.cFileName);
143 #if defined(_WIN32) && !defined(UNDER_CE) 143 #if defined(_WIN32) && !defined(UNDER_CE)
144 // fi.ShortName = fas2fs(fd.cAlternateFileName); 144 // fi.ShortName = fas2fs(fd.cAlternateFileName);
@@ -211,7 +211,7 @@ bool CFindFile::FindFirst(CFSTR path, CFileInfo &fi)
211 211
212 IF_USE_MAIN_PATH 212 IF_USE_MAIN_PATH
213 _handle = ::FindFirstFileW(fs2us(path), &fd); 213 _handle = ::FindFirstFileW(fs2us(path), &fd);
214 #ifdef WIN_LONG_PATH 214 #ifdef Z7_LONG_PATH
215 if (_handle == INVALID_HANDLE_VALUE && USE_SUPER_PATH) 215 if (_handle == INVALID_HANDLE_VALUE && USE_SUPER_PATH)
216 { 216 {
217 UString superPath; 217 UString superPath;
@@ -252,23 +252,27 @@ bool CFindFile::FindNext(CFileInfo &fi)
252//////////////////////////////// 252////////////////////////////////
253// AltStreams 253// AltStreams
254 254
255static FindFirstStreamW_Ptr g_FindFirstStreamW; 255static Func_FindFirstStreamW g_FindFirstStreamW;
256static FindNextStreamW_Ptr g_FindNextStreamW; 256static Func_FindNextStreamW g_FindNextStreamW;
257 257
258static struct CFindStreamLoader 258static struct CFindStreamLoader
259{ 259{
260 CFindStreamLoader() 260 CFindStreamLoader()
261 { 261 {
262 HMODULE hm = ::GetModuleHandleA("kernel32.dll"); 262 const HMODULE hm = ::GetModuleHandleA("kernel32.dll");
263 g_FindFirstStreamW = (FindFirstStreamW_Ptr)(void *)::GetProcAddress(hm, "FindFirstStreamW"); 263 g_FindFirstStreamW = Z7_GET_PROC_ADDRESS(
264 g_FindNextStreamW = (FindNextStreamW_Ptr)(void *)::GetProcAddress(hm, "FindNextStreamW"); 264 Func_FindFirstStreamW, hm,
265 "FindFirstStreamW");
266 g_FindNextStreamW = Z7_GET_PROC_ADDRESS(
267 Func_FindNextStreamW, hm,
268 "FindNextStreamW");
265 } 269 }
266} g_FindStreamLoader; 270} g_FindStreamLoader;
267 271
268bool CStreamInfo::IsMainStream() const throw() 272bool CStreamInfo::IsMainStream() const throw()
269{ 273{
270 return StringsAreEqualNoCase_Ascii(Name, "::$DATA"); 274 return StringsAreEqualNoCase_Ascii(Name, "::$DATA");
271}; 275}
272 276
273UString CStreamInfo::GetReducedName() const 277UString CStreamInfo::GetReducedName() const
274{ 278{
@@ -331,7 +335,7 @@ bool CFindStream::FindFirst(CFSTR path, CStreamInfo &si)
331 if (::GetLastError() == ERROR_HANDLE_EOF) 335 if (::GetLastError() == ERROR_HANDLE_EOF)
332 return false; 336 return false;
333 // long name can be tricky for path like ".\dirName". 337 // long name can be tricky for path like ".\dirName".
334 #ifdef WIN_LONG_PATH 338 #ifdef Z7_LONG_PATH
335 if (USE_SUPER_PATH) 339 if (USE_SUPER_PATH)
336 { 340 {
337 UString superPath; 341 UString superPath;
@@ -414,7 +418,7 @@ DWORD GetFileAttrib(CFSTR path)
414 if (dw != INVALID_FILE_ATTRIBUTES) 418 if (dw != INVALID_FILE_ATTRIBUTES)
415 return dw; 419 return dw;
416 } 420 }
417 #ifdef WIN_LONG_PATH 421 #ifdef Z7_LONG_PATH
418 if (USE_SUPER_PATH) 422 if (USE_SUPER_PATH)
419 { 423 {
420 UString superPath; 424 UString superPath;
@@ -451,7 +455,7 @@ also we support paths that are not supported by FindFirstFile:
451 455
452bool CFileInfo::Find(CFSTR path, bool followLink) 456bool CFileInfo::Find(CFSTR path, bool followLink)
453{ 457{
454 #ifdef SUPPORT_DEVICE_FILE 458 #ifdef Z7_DEVICE_FILE
455 459
456 if (IS_PATH_SEPAR(path[0]) && 460 if (IS_PATH_SEPAR(path[0]) &&
457 IS_PATH_SEPAR(path[1]) && 461 IS_PATH_SEPAR(path[1]) &&
@@ -847,7 +851,7 @@ HANDLE CFindChangeNotification::FindFirst(CFSTR path, bool watchSubtree, DWORD n
847 { 851 {
848 IF_USE_MAIN_PATH 852 IF_USE_MAIN_PATH
849 _handle = ::FindFirstChangeNotificationW(fs2us(path), BoolToBOOL(watchSubtree), notifyFilter); 853 _handle = ::FindFirstChangeNotificationW(fs2us(path), BoolToBOOL(watchSubtree), notifyFilter);
850 #ifdef WIN_LONG_PATH 854 #ifdef Z7_LONG_PATH
851 if (!IsHandleAllocated()) 855 if (!IsHandleAllocated())
852 { 856 {
853 UString superPath; 857 UString superPath;