📄 file.h
字号:
BOOL Exists() const; /**Check for file access modes. Determine if the file specified may be opened in the specified mode. This would check the current access rights to the file for the mode. For example, for a file that is read only, using mode == ReadWrite would return FALSE but mode == ReadOnly would return TRUE. @return TRUE if a file open would succeed. */ static BOOL Access( const PFilePath & name, /// Name of file to have its access checked. OpenMode mode /// Mode in which the file open would be done. ); /**Check for file access modes. Determine if the file path specification associated with the instance of the object may be opened in the specified mode. This would check the current access rights to the file for the mode. For example, for a file that is read only, using mode == ReadWrite would return FALSE but mode == ReadOnly would return TRUE. @return TRUE if a file open would succeed. */ BOOL Access( OpenMode mode /// Mode in which the file open would be done. ); /**Delete the specified file. If #force# is FALSE and the file is protected against being deleted then the function fails. If #force# is TRUE then the protection is ignored. What constitutes file deletion protection is platform dependent, eg on DOS is the Read Only attribute and on a Novell network it is a Delete trustee right. Some protection may not be able to overridden with the #force# parameter at all, eg on a Unix system and you are not the owner of the file. @return TRUE if the file was deleted. */ static BOOL Remove( const PFilePath & name, // Name of file to delete. BOOL force = FALSE // Force deletion even if file is protected. ); /**Delete the current file. If #force# is FALSE and the file is protected against being deleted then the function fails. If #force# is TRUE then the protection is ignored. What constitutes file deletion protection is platform dependent, eg on DOS is the Read Only attribute and on a Novell network it is a Delete trustee right. Some protection may not be able to overridden with the #force# parameter at all, eg on a Unix system and you are not the owner of the file. @return TRUE if the file was deleted. */ BOOL Remove( BOOL force = FALSE // Force deletion even if file is protected. ); /**Change the specified files name. This does not move the file in the directory hierarchy, it only changes the name of the directory entry. The #newname# parameter must consist only of the file name part, as returned by the #PFilePath::GetFileName()# function. Any other file path parts will cause an error. The first form uses the file path specification associated with the instance of the object. The name within the instance is changed to the new name if the function succeeds. The second static function uses an arbitrary file specified by name. @return TRUE if the file was renamed. */ static BOOL Rename( const PFilePath & oldname, /// Old name of the file. const PString & newname, /// New name for the file. BOOL force = FALSE /// Delete file if a destination exists with the same name. ); /**Change the current files name. This does not move the file in the directory hierarchy, it only changes the name of the directory entry. The #newname# parameter must consist only of the file name part, as returned by the #PFilePath::GetFileName()# function. Any other file path parts will cause an error. The first form uses the file path specification associated with the instance of the object. The name within the instance is changed to the new name if the function succeeds. The second static function uses an arbitrary file specified by name. @return TRUE if the file was renamed. */ BOOL Rename( const PString & newname, /// New name for the file. BOOL force = FALSE /// Delete file if a destination exists with the same name. ); /**Make a copy of the specified file. @return TRUE if the file was renamed. */ static BOOL Copy( const PFilePath & oldname, /// Old name of the file. const PFilePath & newname, /// New name for the file. BOOL force = FALSE /// Delete file if a destination exists with the same name. ); /**Make a copy of the current file. @return TRUE if the file was renamed. */ BOOL Copy( const PFilePath & newname, /// New name for the file. BOOL force = FALSE /// Delete file if a destination exists with the same name. ); /**Move the specified file. This will move the file from one position in the directory hierarchy to another position. The actual operation is platform dependent but the reslt is the same. For instance, for Unix, if the move is within a file system then a simple rename is done, if it is across file systems then a copy and a delete is performed. @return TRUE if the file was moved. */ static BOOL Move( const PFilePath & oldname, /// Old path and name of the file. const PFilePath & newname, /// New path and name for the file. BOOL force = FALSE /// Delete file if a destination exists with the same name. ); /**Move the current file. This will move the file from one position in the directory hierarchy to another position. The actual operation is platform dependent but the reslt is the same. For instance, for Unix, if the move is within a file system then a simple rename is done, if it is across file systems then a copy and a delete is performed. @return TRUE if the file was moved. */ BOOL Move( const PFilePath & newname, /// New path and name for the file. BOOL force = FALSE /// Delete file if a destination exists with the same name. ); //@} /**@name File channel functions */ //@{ /**Get the full path name of the file. The #PFilePath# object describes the full file name specification for the particular platform. @return the name of the file. */ const PFilePath & GetFilePath() const; /**Set the full path name of the file. The #PFilePath# object describes the full file name specification for the particular platform. */ void SetFilePath( const PString & path /// New file path. ); /**Open the current file in the specified mode and with the specified options. If the file object already has an open file then it is closed. If there has not been a filename attached to the file object (via #SetFilePath()#, the #name# parameter or a previous open) then a new unique temporary filename is generated. @return TRUE if the file was successfully opened. */ BOOL Open( OpenMode mode = ReadWrite, // Mode in which to open the file. int opts = ModeDefault // Options for open operation. ); /**Open the specified file name in the specified mode and with the specified options. If the file object already has an open file then it is closed. Note: if #mode# is StandardInput, StandardOutput or StandardError, then the #name# parameter is ignored. @return TRUE if the file was successfully opened. */ BOOL Open( const PFilePath & name, // Name of file to open. OpenMode mode = ReadWrite, // Mode in which to open the file. int opts = ModeDefault // #OpenOptions enum# for open operation. ); /**Get the current size of the file. @return length of file in bytes. */ off_t GetLength() const; /**Set the size of the file, padding with 0 bytes if it would require expanding the file, or truncating it if being made shorter. @return TRUE if the file size was changed to the length specified. */ BOOL SetLength( off_t len // New length of file. ); /// Options for the origin in setting the file position. enum FilePositionOrigin { /// Set position relative to start of file. Start = SEEK_SET, /// Set position relative to current file position. Current = SEEK_CUR, /// Set position relative to end of file. End = SEEK_END }; /**Set the current active position in the file for the next read or write operation. The #pos# variable is a signed number which is added to the specified origin. For #origin == PFile::Start# only positive values for #pos# are meaningful. For #origin == PFile::End# only negative values for #pos# are meaningful. @return TRUE if the new file position was set. */ BOOL SetPosition( off_t pos, /// New position to set. FilePositionOrigin origin = Start /// Origin for position change. ); /**Get the current active position in the file for the next read or write operation. @return current file position relative to start of file. */ off_t GetPosition() const; /**Determine if the current file position is at the end of the file. If this is TRUE then any read operation will fail. @return TRUE if at end of file. */ BOOL IsEndOfFile() const; /**Get information (eg protection, timestamps) on the specified file. @return TRUE if the file info was retrieved. */ static BOOL GetInfo( const PFilePath & name, // Name of file to get the information on. PFileInfo & info // #PFileInfo# structure to receive the information. ); /**Get information (eg protection, timestamps) on the current file. @return TRUE if the file info was retrieved. */ BOOL GetInfo( PFileInfo & info // #PFileInfo# structure to receive the information. ); /**Set permissions on the specified file. @return TRUE if the file was renamed. */ static BOOL SetPermissions( const PFilePath & name, // Name of file to change the permission of. int permissions // New permissions mask for the file. ); /**Set permissions on the current file. @return TRUE if the file was renamed. */ BOOL SetPermissions( int permissions // New permissions mask for the file. ); //@} protected: // Member variables /// The fully qualified path name for the file. PFilePath path; /// File is to be removed when closed. BOOL removeOnClose; #ifdef DOC_PLUS_PLUS};#endif// Class declaration continued in platform specific header file ///////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -