diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-06-21 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:59:19 +0500 |
| commit | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch) | |
| tree | fe5e17420300b715021a76328444088d32047963 /CPP/Windows/FileFind.cpp | |
| parent | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff) | |
| download | 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.tar.gz 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.tar.bz2 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.zip | |
23.0123.01
Diffstat (limited to 'CPP/Windows/FileFind.cpp')
| -rw-r--r-- | CPP/Windows/FileFind.cpp | 36 |
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 | ||
| 42 | typedef HANDLE (WINAPI *FindFirstStreamW_Ptr)(LPCWSTR fileName, MY_STREAM_INFO_LEVELS infoLevel, | 42 | typedef HANDLE (WINAPI *Func_FindFirstStreamW)(LPCWSTR fileName, MY_STREAM_INFO_LEVELS infoLevel, |
| 43 | LPVOID findStreamData, DWORD flags); | 43 | LPVOID findStreamData, DWORD flags); |
| 44 | 44 | ||
| 45 | typedef BOOL (APIENTRY *FindNextStreamW_Ptr)(HANDLE findStream, LPVOID findStreamData); | 45 | typedef BOOL (APIENTRY *Func_FindNextStreamW)(HANDLE findStream, LPVOID findStreamData); |
| 46 | 46 | ||
| 47 | EXTERN_C_END | 47 | EXTERN_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 |
| 58 | namespace NSystem | 58 | namespace NSystem |
| 59 | { | 59 | { |
| 60 | bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize); | 60 | bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize); |
| @@ -128,7 +128,7 @@ bool CFileInfo::IsDots() const throw() | |||
| 128 | 128 | ||
| 129 | static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATAW &fd, CFileInfo &fi) | 129 | static 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 |
| 139 | static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATA &fd, CFileInfo &fi) | 139 | static 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 | ||
| 255 | static FindFirstStreamW_Ptr g_FindFirstStreamW; | 255 | static Func_FindFirstStreamW g_FindFirstStreamW; |
| 256 | static FindNextStreamW_Ptr g_FindNextStreamW; | 256 | static Func_FindNextStreamW g_FindNextStreamW; |
| 257 | 257 | ||
| 258 | static struct CFindStreamLoader | 258 | static 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 | ||
| 268 | bool CStreamInfo::IsMainStream() const throw() | 272 | bool CStreamInfo::IsMainStream() const throw() |
| 269 | { | 273 | { |
| 270 | return StringsAreEqualNoCase_Ascii(Name, "::$DATA"); | 274 | return StringsAreEqualNoCase_Ascii(Name, "::$DATA"); |
| 271 | }; | 275 | } |
| 272 | 276 | ||
| 273 | UString CStreamInfo::GetReducedName() const | 277 | UString 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 | ||
| 452 | bool CFileInfo::Find(CFSTR path, bool followLink) | 456 | bool 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; |
