diff options
Diffstat (limited to 'src/libs/7zip/win/CPP/Windows/FileFind.h')
-rw-r--r-- | src/libs/7zip/win/CPP/Windows/FileFind.h | 127 |
1 files changed, 62 insertions, 65 deletions
diff --git a/src/libs/7zip/win/CPP/Windows/FileFind.h b/src/libs/7zip/win/CPP/Windows/FileFind.h index 63631f66b..aaa7499bd 100644 --- a/src/libs/7zip/win/CPP/Windows/FileFind.h +++ b/src/libs/7zip/win/CPP/Windows/FileFind.h @@ -1,12 +1,10 @@ // Windows/FileFind.h -#ifndef __WINDOWS_FILEFIND_H -#define __WINDOWS_FILEFIND_H +#ifndef __WINDOWS_FILE_FIND_H +#define __WINDOWS_FILE_FIND_H #include "../Common/MyString.h" -#include "../Common/Types.h" #include "Defs.h" -#include "FileName.h" namespace NWindows { namespace NFile { @@ -26,14 +24,13 @@ namespace NAttributes class CFileInfoBase { bool MatchesMask(UINT32 mask) const { return ((Attrib & mask) != 0); } -protected: - void Clear(); public: UInt64 Size; FILETIME CTime; FILETIME ATime; FILETIME MTime; DWORD Attrib; + bool IsAltStream; bool IsDevice; /* @@ -44,6 +41,11 @@ public: #endif */ + CFileInfoBase() { Clear(); } + void Clear() throw(); + + void SetAsDir() { Attrib = FILE_ATTRIBUTE_DIRECTORY; } + bool IsArchived() const { return MatchesMask(FILE_ATTRIBUTE_ARCHIVE); } bool IsCompressed() const { return MatchesMask(FILE_ATTRIBUTE_COMPRESSED); } bool IsDir() const { return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); } @@ -60,78 +62,80 @@ public: struct CFileInfo: public CFileInfoBase { - CSysString Name; + FString Name; + #if defined(_WIN32) && !defined(UNDER_CE) + // FString ShortName; + #endif + + bool IsDots() const throw(); + bool Find(CFSTR wildcard); +}; + +class CFindFileBase +{ +protected: + HANDLE _handle; +public: + bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE; } + CFindFileBase(): _handle(INVALID_HANDLE_VALUE) {} + ~CFindFileBase() { Close(); } + bool Close() throw(); +}; - bool IsDots() const; - bool Find(LPCTSTR wildcard); +class CFindFile: public CFindFileBase +{ +public: + bool FindFirst(CFSTR wildcard, CFileInfo &fileInfo); + bool FindNext(CFileInfo &fileInfo); }; -#ifdef _UNICODE -typedef CFileInfo CFileInfoW; -#else -struct CFileInfoW: public CFileInfoBase +#if defined(_WIN32) && !defined(UNDER_CE) + +struct CStreamInfo { UString Name; + UInt64 Size; - bool IsDots() const; - bool Find(LPCWSTR wildcard); + UString GetReducedName() const; + bool IsMainStream() const throw(); }; -#endif -class CFindFile +class CFindStream: public CFindFileBase { - friend class CEnumerator; - HANDLE _handle; public: - bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE; } - CFindFile(): _handle(INVALID_HANDLE_VALUE) {} - ~CFindFile() { Close(); } - bool FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo); - bool FindNext(CFileInfo &fileInfo); - #ifndef _UNICODE - bool FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo); - bool FindNext(CFileInfoW &fileInfo); - #endif - bool Close(); + bool FindFirst(CFSTR filePath, CStreamInfo &streamInfo); + bool FindNext(CStreamInfo &streamInfo); +}; + +class CStreamEnumerator +{ + CFindStream _find; + FString _filePath; + + bool NextAny(CFileInfo &fileInfo); +public: + CStreamEnumerator(const FString &filePath): _filePath(filePath) {} + bool Next(CStreamInfo &streamInfo, bool &found); }; -bool DoesFileExist(LPCTSTR name); -bool DoesDirExist(LPCTSTR name); -bool DoesFileOrDirExist(LPCTSTR name); -#ifndef _UNICODE -bool DoesFileExist(LPCWSTR name); -bool DoesDirExist(LPCWSTR name); -bool DoesFileOrDirExist(LPCWSTR name); #endif +bool DoesFileExist(CFSTR name); +bool DoesDirExist(CFSTR name); +bool DoesFileOrDirExist(CFSTR name); + class CEnumerator { CFindFile _findFile; - CSysString _wildcard; + FString _wildcard; + bool NextAny(CFileInfo &fileInfo); public: - CEnumerator(): _wildcard(NName::kAnyStringWildcard) {} - CEnumerator(const CSysString &wildcard): _wildcard(wildcard) {} + CEnumerator(const FString &wildcard): _wildcard(wildcard) {} bool Next(CFileInfo &fileInfo); bool Next(CFileInfo &fileInfo, bool &found); }; -#ifdef _UNICODE -typedef CEnumerator CEnumeratorW; -#else -class CEnumeratorW -{ - CFindFile _findFile; - UString _wildcard; - bool NextAny(CFileInfoW &fileInfo); -public: - CEnumeratorW(): _wildcard(NName::kAnyStringWildcard) {} - CEnumeratorW(const UString &wildcard): _wildcard(wildcard) {} - bool Next(CFileInfoW &fileInfo); - bool Next(CFileInfoW &fileInfo, bool &found); -}; -#endif - class CFindChangeNotification { HANDLE _handle; @@ -140,22 +144,15 @@ public: bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE && _handle != 0; } CFindChangeNotification(): _handle(INVALID_HANDLE_VALUE) {} ~CFindChangeNotification() { Close(); } - bool Close(); - HANDLE FindFirst(LPCTSTR pathName, bool watchSubtree, DWORD notifyFilter); - #ifndef _UNICODE - HANDLE FindFirst(LPCWSTR pathName, bool watchSubtree, DWORD notifyFilter); - #endif + bool Close() throw(); + HANDLE FindFirst(CFSTR pathName, bool watchSubtree, DWORD notifyFilter); bool FindNext() { return BOOLToBool(::FindNextChangeNotification(_handle)); } }; #ifndef UNDER_CE -bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings); -#ifndef _UNICODE -bool MyGetLogicalDriveStrings(UStringVector &driveStrings); -#endif +bool MyGetLogicalDriveStrings(CObjectVector<FString> &driveStrings); #endif }}} #endif - |