This class represents a disk file.
![]() | Construction |
![]() | Overrides from class PObject |
![]() | Overrides from class PChannel |
![]() | File manipulation functions |
![]() | File channel functions |
![]() | path The fully qualified path name for the file. |
![]() | removeOnClose File is to be removed when closed. |
Information functions
Reading functions
Writing functions
Miscellaneous functions
Error functions
Run Time Type functions
Comparison functions
I/O functions
This class represents a disk file. This is a particular type of I/O channel that has certain attributes. All platforms have a disk file, though exact details of naming convertions etc may be different.The basic model for files is that they are a named sequence of bytes that persists within a directory structure. The transfer of data to and from the file is made at a current position in the file. This may be set to random locations within the file.
The ModeDefault option will use the following values:
The PChannel::IsOpen() function may be used after object
construction to determine if the file was successfully opened.
The PChannel::IsOpen() function may be used after object
construction to determine if the file was successfully opened.
enum OpenMode
enum OpenOptions
Mode Options
ReadOnly MustExist
WriteOnly Create | Truncate
ReadWrite Create
ModeDefault
MustExist
Create
Truncate
Exclusive
Temporary
PFile( OpenMode mode, int opts = ModeDefault )
opts - OpenOptions enum for open operation. PFile( const PFilePath & name, OpenMode mode = ReadWrite, int opts = ModeDefault )
mode - Mode in which to open the file.
opts - OpenOptions enum for open operation.
The GetErrorCode() function should be consulted after Read() returns
FALSE to determine what caused the failure.
The GetErrorCode() function should be consulted after Write() returns
FALSE to determine what caused the failure.
virtual BOOL Read( void * buf, PINDEX len )
len - Maximum number of bytes to read into the buffer.virtual BOOL Write( const void * buf, PINDEX len )
len - Number of bytes to write.virtual BOOL Close()
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.
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.
BOOL Exists() const
static BOOL Access( const PFilePath & name, OpenMode mode )
mode - Mode in which the file open would be done.BOOL Access( OpenMode mode )
static BOOL Remove( const PFilePath & name, BOOL force = FALSE )
BOOL Remove( BOOL force = FALSE )
static BOOL Rename( const PFilePath & oldname, const PString & newname, BOOL force = FALSE )
newname - New name for the file.
force - Delete file if a destination exists with the same name.BOOL Rename( const PString & newname, BOOL force = FALSE )
force - Delete file if a destination exists with the same name.static BOOL Copy( const PFilePath & oldname, const PFilePath & newname, BOOL force = FALSE )
newname - New name for the file.
force - Delete file if a destination exists with the same name.BOOL Copy( const PFilePath & newname, BOOL force = FALSE )
force - Delete file if a destination exists with the same name.static BOOL Move( const PFilePath & oldname, const PFilePath & newname, BOOL force = FALSE )
newname - New path and name for the file.
force - Delete file if a destination exists with the same name.BOOL Move( const PFilePath & newname, BOOL force = FALSE )
force - Delete file if a destination exists with the same name.
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.
Note: if mode is StandardInput, StandardOutput or StandardError,
then the name parameter is ignored.
void SetFilePath( const PString & path )
virtual BOOL Open( OpenMode mode = ReadWrite, int opts = ModeDefault )
BOOL Open( const PFilePath & name, OpenMode mode = ReadWrite, int opts = ModeDefault )
off_t GetLength() const
BOOL SetLength( off_t len )
enum FilePositionOrigin
Start
BOOL SetPosition( off_t pos, FilePositionOrigin origin = Start )
origin - Origin for position change.off_t GetPosition() const
BOOL IsEndOfFile() const
static BOOL GetInfo( const PFilePath & name, PFileInfo & info )
BOOL GetInfo( PFileInfo & info )
static BOOL SetPermissions( const PFilePath & name, int permissions )
BOOL SetPermissions( int permissions )
Alphabetic index HTML hierarchy of classes or Java