www.pudn.com > VC写的MP3播放器源代码.zip > ITFindFiles.h
///////////////////////////////////////////////////////////////////////////// #ifndef ITFINDFILES_INCLUDED #define ITFINDFILES_INCLUDED #include "ITSimpleFindFiles.h" class ITCFindFiles; ///////////////////////////////////////////////////////////////////////////// // // @doc EXTERNAL UTILITY // // @func BOOL | FindFileEnumProc | Thefunction is an // application-defined callback function used with the // method. The type defines a pointer to this callback // function. is a placeholder for the application-defined // function name. // // @parm ITCFindFiles* | pFind | A pointer to the . This object // can be queried to determine attributes of the file found. // @parm LONG | lParam | Specifies the application-defined parameter. // // @rdesc Return nonzero to continue the search; otherwise 0. // // @xref typedef BOOL (CALLBACK * ITCFINDFILESENUMPROC)(ITCFindFiles* pFind, LONG lParam); ///////////////////////////////////////////////////////////////////////////// // ITCFindFiles // // @doc EXTERNAL UTILITY // // @class The class searches a folder for a file or subfolder // whose name matches a specified filename or pattern. Subfolders can also // be included in the search. // // This class performs searches based on file name and file attributes. // You can override to perform more advanced // filtering. // // The current directory and parent directory markers, directories with // the name "." or "..", are not returned while searching. // // @base public | // // @ex The following example shows how you would search for all the // non-system files on the C drive.| // // ITCFindFiles find; // // find.NewSearch("C:\\", "*.*", ITCFindFiles::DefaultAttributes, // ITCFindFiles::IncludeSubfolders); // // while (find.NextFile()) // { // TRACE("%s\n", find.GetFilePath()); // } // // @author Lance Lovette | class ITCFindFiles : public CObject { DECLARE_DYNAMIC(ITCFindFiles) // Data constants public: static DWORD None; static DWORD IncludeSubfolders; static DWORD SearchingSubfolders; // Used internally static DWORD AllAttributes; // Use with NewSearch. static DWORD DefaultAttributes; // Use with NewSearch. static DWORD FilesOnly; // Use with NewSearch. static DWORD FoldersOnly; // Use with NewSearch. // @access Construction public: // @cmember Constructs a object. ITCFindFiles(); // @cmember Begins a new search. virtual void NewSearch(CString strPattern, DWORD dwFindAttributes, DWORD dwFindFlags); virtual void NewSearch(CString strFolder, CString strPattern, DWORD dwFindAttributes, DWORD dwFindFlags); void NewSearch(HDROP hDropInfo, DWORD dwFindAttributes, DWORD dwFindFlags); // @access Attributes public: // @cmember Gets the attributes of the found file. DWORD GetFileAttributes() const; // @cmember Gets the extension of the found file. CString GetFileExt() const; // @cmember Gets the folder containing the found file. CString GetFileFolder() const; // @cmember Gets the name, including the extension, of the found file. LPCTSTR GetFileName() const; // @cmember Gets the full path of the found file. CString GetFilePath() const; // @cmember Gets the title of the found file. // The title does not include the extension. CString GetFileTitle() const; // @cmember Gets the file attributes that are being used // to filter the search. void GetFindAttributes(DWORD& dwAttribSet, DWORD& dwAttribClear) const; // @cmember Gets the structure for the found file. const WIN32_FIND_DATA* GetFindData() const; // @cmember Gets the complete search pattern used to find the file. CString GetFindFileName() const; // @cmember Gets the file pattern that is filtering the search. CString GetFindPattern() const; // @cmember Gets the length of the found file, in bytes. DWORD GetLength() const; // @cmember Gets the root folder of the found file. CString GetRoot() const; // @cmember Retrieve the string that describes the file's type. CString GetTypeName() const; // @cmember Determines if the found file has the specified file // attributes. BOOL HasFileAttributes(DWORD dwFileAttributes) const; // @cmember Determines if the found file is archived. BOOL IsArchived() const; // @cmember Determines if the found file is compressed. BOOL IsCompressed() const; // @cmember Determines if the found file is a folder. BOOL IsFolder() const; // @cmember Determines if the found file is hidden. BOOL IsHidden() const; // @cmember Determines if the found file is normal. BOOL IsNormal() const; // @cmember Determines if the found file is offline. BOOL IsOffline() const; // @cmember Determines if the found file is read-only. BOOL IsReadOnly() const; // @cmember Determines if the found file is a system file. BOOL IsSystem() const; // @cmember Determines if the found file is temporary. BOOL IsTemporary() const; // @cmember Sets the function to be called for each file found. ITCFINDFILESENUMPROC SetCallback(ITCFINDFILESENUMPROC lpEnumProc, LONG lParam); // @cmember Sets the file attributes that are being used // to filter the search. void SetFindAttributes(DWORD dwAttribSet, DWORD dwAttribClear); // @cmember Retrieves shell information about the found file. DWORD SHGetFileInfo(DWORD dwFileAttributes, SHFILEINFO FAR *psfi, UINT uFlags) const; // @access Operations public: // @cmember Builds a list of the files found by the search. BOOL BuildFileList(CStringArray& rFileList); // @cmember Closes the search. virtual void CloseSearch(); // @cmember Continues the file search. virtual BOOL NextFile(); // @cmember Counts the number of files in the search. BOOL GetFileCount(DWORD& dwCount); // @access Overridables public: // @cmember Called to determine if a file should be part of the search. virtual BOOL OnFilterFile() const; // @cmember Called each time a file is found. virtual BOOL OnFindFile(); // @cmember Called each time a folder needs to be searched. virtual void OnSearchSubfolder(); // Implementation public: virtual ~ITCFindFiles(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: LONG m_lEnumParam; ITCFINDFILESENUMPROC m_lpEnumProc; CList m_findStack; virtual BOOL NextFindFile(); virtual BOOL NextDropFile(); }; // // @xref ///////////////////////////////////////////////////////////////////////////// #endif // ITFINDFILES_INCLUDED