Mercurial > vba-clojure
diff src/win32/7zip/7z/CPP/Windows/FileFind.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/Windows/FileFind.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,153 @@ 1.4 +// Windows/FileFind.h 1.5 + 1.6 +#ifndef __WINDOWS_FILEFIND_H 1.7 +#define __WINDOWS_FILEFIND_H 1.8 + 1.9 +#include "../Common/MyString.h" 1.10 +#include "../Common/Types.h" 1.11 +#include "FileName.h" 1.12 +#include "Defs.h" 1.13 + 1.14 +namespace NWindows { 1.15 +namespace NFile { 1.16 +namespace NFind { 1.17 + 1.18 +namespace NAttributes 1.19 +{ 1.20 + inline bool IsReadOnly(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_READONLY) != 0; } 1.21 + inline bool IsHidden(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_HIDDEN) != 0; } 1.22 + inline bool IsSystem(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_SYSTEM) != 0; } 1.23 + inline bool IsDir(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0; } 1.24 + inline bool IsArchived(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_ARCHIVE) != 0; } 1.25 + inline bool IsCompressed(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_COMPRESSED) != 0; } 1.26 + inline bool IsEncrypted(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_ENCRYPTED) != 0; } 1.27 +} 1.28 + 1.29 +class CFileInfoBase 1.30 +{ 1.31 + bool MatchesMask(UINT32 mask) const { return ((Attrib & mask) != 0); } 1.32 +public: 1.33 + UInt64 Size; 1.34 + FILETIME CTime; 1.35 + FILETIME ATime; 1.36 + FILETIME MTime; 1.37 + DWORD Attrib; 1.38 + 1.39 + #ifndef _WIN32_WCE 1.40 + UINT32 ReparseTag; 1.41 + #else 1.42 + DWORD ObjectID; 1.43 + #endif 1.44 + 1.45 + bool IsArchived() const { return MatchesMask(FILE_ATTRIBUTE_ARCHIVE); } 1.46 + bool IsCompressed() const { return MatchesMask(FILE_ATTRIBUTE_COMPRESSED); } 1.47 + bool IsDir() const { return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); } 1.48 + bool IsEncrypted() const { return MatchesMask(FILE_ATTRIBUTE_ENCRYPTED); } 1.49 + bool IsHidden() const { return MatchesMask(FILE_ATTRIBUTE_HIDDEN); } 1.50 + bool IsNormal() const { return MatchesMask(FILE_ATTRIBUTE_NORMAL); } 1.51 + bool IsOffline() const { return MatchesMask(FILE_ATTRIBUTE_OFFLINE); } 1.52 + bool IsReadOnly() const { return MatchesMask(FILE_ATTRIBUTE_READONLY); } 1.53 + bool HasReparsePoint() const { return MatchesMask(FILE_ATTRIBUTE_REPARSE_POINT); } 1.54 + bool IsSparse() const { return MatchesMask(FILE_ATTRIBUTE_SPARSE_FILE); } 1.55 + bool IsSystem() const { return MatchesMask(FILE_ATTRIBUTE_SYSTEM); } 1.56 + bool IsTemporary() const { return MatchesMask(FILE_ATTRIBUTE_TEMPORARY); } 1.57 +}; 1.58 + 1.59 +class CFileInfo: public CFileInfoBase 1.60 +{ 1.61 +public: 1.62 + CSysString Name; 1.63 + bool IsDots() const; 1.64 +}; 1.65 + 1.66 +#ifdef _UNICODE 1.67 +typedef CFileInfo CFileInfoW; 1.68 +#else 1.69 +class CFileInfoW: public CFileInfoBase 1.70 +{ 1.71 +public: 1.72 + UString Name; 1.73 + bool IsDots() const; 1.74 +}; 1.75 +#endif 1.76 + 1.77 +class CFindFile 1.78 +{ 1.79 + friend class CEnumerator; 1.80 + HANDLE _handle; 1.81 +public: 1.82 + bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE; } 1.83 + CFindFile(): _handle(INVALID_HANDLE_VALUE) {} 1.84 + ~CFindFile() { Close(); } 1.85 + bool FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo); 1.86 + bool FindNext(CFileInfo &fileInfo); 1.87 + #ifndef _UNICODE 1.88 + bool FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo); 1.89 + bool FindNext(CFileInfoW &fileInfo); 1.90 + #endif 1.91 + bool Close(); 1.92 +}; 1.93 + 1.94 +bool FindFile(LPCTSTR wildcard, CFileInfo &fileInfo); 1.95 + 1.96 +bool DoesFileExist(LPCTSTR name); 1.97 +#ifndef _UNICODE 1.98 +bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo); 1.99 +bool DoesFileExist(LPCWSTR name); 1.100 +#endif 1.101 + 1.102 +class CEnumerator 1.103 +{ 1.104 + CFindFile _findFile; 1.105 + CSysString _wildcard; 1.106 + bool NextAny(CFileInfo &fileInfo); 1.107 +public: 1.108 + CEnumerator(): _wildcard(NName::kAnyStringWildcard) {} 1.109 + CEnumerator(const CSysString &wildcard): _wildcard(wildcard) {} 1.110 + bool Next(CFileInfo &fileInfo); 1.111 + bool Next(CFileInfo &fileInfo, bool &found); 1.112 +}; 1.113 + 1.114 +#ifdef _UNICODE 1.115 +typedef CEnumerator CEnumeratorW; 1.116 +#else 1.117 +class CEnumeratorW 1.118 +{ 1.119 + CFindFile _findFile; 1.120 + UString _wildcard; 1.121 + bool NextAny(CFileInfoW &fileInfo); 1.122 +public: 1.123 + CEnumeratorW(): _wildcard(NName::kAnyStringWildcard) {} 1.124 + CEnumeratorW(const UString &wildcard): _wildcard(wildcard) {} 1.125 + bool Next(CFileInfoW &fileInfo); 1.126 + bool Next(CFileInfoW &fileInfo, bool &found); 1.127 +}; 1.128 +#endif 1.129 + 1.130 +class CFindChangeNotification 1.131 +{ 1.132 + HANDLE _handle; 1.133 +public: 1.134 + operator HANDLE () { return _handle; } 1.135 + bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE && _handle != 0; } 1.136 + CFindChangeNotification(): _handle(INVALID_HANDLE_VALUE) {} 1.137 + ~CFindChangeNotification() { Close(); } 1.138 + bool Close(); 1.139 + HANDLE FindFirst(LPCTSTR pathName, bool watchSubtree, DWORD notifyFilter); 1.140 + #ifndef _UNICODE 1.141 + HANDLE FindFirst(LPCWSTR pathName, bool watchSubtree, DWORD notifyFilter); 1.142 + #endif 1.143 + bool FindNext() { return BOOLToBool(::FindNextChangeNotification(_handle)); } 1.144 +}; 1.145 + 1.146 +#ifndef _WIN32_WCE 1.147 +bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings); 1.148 +#ifndef _UNICODE 1.149 +bool MyGetLogicalDriveStrings(UStringVector &driveStrings); 1.150 +#endif 1.151 +#endif 1.152 + 1.153 +}}} 1.154 + 1.155 +#endif 1.156 +