Cfilefind class usage Summary

Source: Internet
Author: User
Tags filetime

1. The cfilefind class declaration file is stored in the afx. h header file. 2. Functions of this class: execute local file search (find a specific file and find a specific file x *. x *, search for all files *. *) 3. The cfilefind class is the base class of the cgopherfilefind and cftpfilefind classes. 4. the constructor of the cfilefind class: cfilefind () and close function: Close () will be used in pairs. 5. The member functions of the cfilefind class are divided into three categories based on their operation features: search operation class, get File Attribute Class, and Judge File Attribute Class. (Below I will first list the parameters that do not fully describe the function) Find the operation class: findfile ();: findnextfile (); get the File Attribute Class: getcreationtime ();: getlastaccesstime ();: getlastwritetime ();: getfilename ();: getroot ();: getfilepath ();: getfiletitle ();:: getfileurl ();: getlength (); File Attribute Class: isarchived ();: iscompressed ();: isdirectory ();: isdots ();:: ishidden ();: isnormal ();: isreadonly ();: issystem ();: istemporary ();: matchesmask (); 6, cf The member functions in the ilefind class use the sequence that should be noted after the cfilefind object is created, execute the: findfile () function first, then execute: findnextfile (), then select the function to execute (obtain the File Attribute Class) or (judge the File Attribute Class) function. 7. Detailed analysis of cfilefind class member functions virtual bool findfile (lpctstr pstrname = NULL, DWORD dwunused = 0); if this function returns a value other than 0, the execution is successful, 0 indicates that the execution is unsuccessful. Pstrname: the name of the file to be searched. For example, "E: // programming tool // VC ++ // mfc .rar" and "E: // programming tool // VC ++ // MFC *. RAR "," E: // programming tool // VC ++ //*. * ", or null indicates" *. *". Dwunused: The value must be 0 virtual bool findnextfile (). If the return value of this function is not 0, There are files that meet the conditions. 0 indicates the last file. Virtual bool getcreationtime (filetime * pfiletime) const; virtual bool getcreationtime (ctime & reftime) const; this function is used to obtain the creation time of a file found, if the return value is not 0, the creation time is successfully obtained. If the return value is 0, the execution fails to obtain the creation time or the findnextfile () is not executed. Filetime *: The structure pointer to hold the time ctime &: Address of the object containing the time. Here we will introduce the processing method for converting filetime and ctime: filetime to ctime: a. during initialization, The ctime object can pass the filetime structure filetime ft; ctime time (FT); B. Convert filetime to systemtime, then, the ctime object can pass the systemtime structure filetime ft; systemtime st; bool bsuccess =: filetimetosystemtime (& ft, & St); ctime time (ST ); ctime to filetime method: ctime time (ctime: getcurrenttime (); systemtime st; time. getassystemtime (ST); filetime FT;: systemtimetofiletime (& St, & ft); Virtual bool getlastaccesstime (filetime * pfiletime) const; virtual bool getlastaccesstime (ctime & reftime) const; this function is used to obtain the last access time of a file. If the value is not 0, the execution is successful. If the value is 0, the execution fails or the findnextfile () function is not executed. Virtual bool getlastwritetime (filetime * pfiletime) const; virtual bool getlastwritetime (ctime & reftime) const; this function is used to obtain the last time a file is accessed. A value other than 0 indicates that the execution is successful, 0 indicates that the execution fails or the findnextfile () function is not executed. Virtual cstring getfilepath () const; this function is used to obtain the absolute path of the searched file. The function can be successfully executed only after findnextfile () is executed. The returned result is a cstring object, for example, "E: // programming tool // VC ++ // mfc.rar" virtual cstring getfilename () const; this function is used to obtain the full name of the searched file. The function can be successfully executed only after findnextfile () is executed. The return result is a cstringobject. For example, mfc.rar "virtual cstring getfiletitle () const; this function is used to obtain the name of the searched file. The function can be successfully executed only after findnextfile () is executed. The returned result is a cstring object. For example, "MFC" virtual cstring getroot () Const. This function is used to obtain the root directory of the searched file and must be executed in findnextfile () then the function can be successfully executed. The returned result is a cstring object, for example, "E: // programming tool // VC ++ //" virtual cstring getfileurl () const; this function is used to obtain the URL path of the searched file. The function can be successfully executed only after findnextfile () is executed. The returned result is a cstring object, for example, "file: // E: // programming tool // VC ++ // mfc.rar" DWORD getlength () const; the return value of this function obtains the length of the searched file. The function can be successfully executed only after findnextfile () is executed. Bool isarchived () const; this function is used to determine whether the file attribute to be searched is an archive file. If it is not 0, it indicates yes, and if it is 0, it indicates no. This function can be successfully executed only after findnextfile () is executed. bool iscompressed () const is used to determine whether the file attribute to be searched is a compressed file. If it is not 0, it indicates yes, and 0 indicates no. This function can be successfully executed only after findnextfile () is executed by bool isdirectory () Const. This function is used to determine whether the file attribute is a path file. If it is not 0, it indicates yes, and if it is 0, it indicates no. This function can be successfully executed only after findnextfile () is executed. bool isdots () const is used to determine whether the file attribute to be searched is ". ","... ", non-0 indicates yes, and 0 indicates no. The function can be successfully executed only after findnextfile () is executed. bool ishidden () const () is used to determine whether the file properties to be searched are hidden. If it is not 0, Yes indicates yes, and 0 indicates no. The function can be successfully executed only after findnextfile () is executed. bool isnormal () const is used to determine whether the file attribute to be searched is a normal file. If it is not 0, yes is used, and 0 indicates no. This function can be successfully executed only after findnextfile () is executed. bool isreadonly () const is used to determine whether the file attribute to be searched is a read-only file. If it is not 0, yes is used, and 0 indicates no. This function can be successfully executed only after findnextfile () is executed by bool issystem () Const. This function is used to determine whether the file attribute to be searched is a system file. If it is not 0, yes, and 0 indicates no. This function can be successfully executed only after findnextfile () is executed. bool istemporary () const is used to determine whether the file attribute to be searched is a temporary file. If it is not 0, it indicates yes, and 0 indicates no. This function can be successfully executed only after findnextfile () is executed. bool matchesmask (DWORD dwmask) const is used to determine the comprehensive attribute of the searched file. If it is not 0, it indicates yes, 0 indicates no. The function must be executed after findnextfile () is executed to use the dwmask parameter. usage of the dwmask parameter is as follows: Structure Definition of file attributes using the or operation (|): file_attribute_archive: file file_attribute_compressed: compressed file file_attribute_directory: path file file_attribute_normal: normal file file_attribute_readonly: Read-Only file file_attribute_system: System File file_attribute_temporary: temporary file file_attribute_hidden: Hide File

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.