oaFile Class Reference

Inheritance diagram for oaFile:

oaFSComponent


Public Methods

 oaFile (const oaString &nameIn)
virtual ~oaFile ()
void open (oaChar modeIn)
void close ()
void flush ()
oaUInt4 read (void *data, oaUInt4 numBytes)
oaUInt4 write (void *data, oaUInt4 numBytes)
virtual oaBoolean exists () const
oaBoolean isOpen () const
oaBoolean isNonEmpty () const
oaChar getMode () const
oaUInt8 getSize () const
oaTime getLastWriteTime () const
oaTime getCreateTime () const

Static Public Methods

void copyFile (const oaString &srcPath, const oaString &dstPath)

Detailed Description

The oaFile utility class implements an object for managing a disk file, including functions for getting system information about, locking, and removing a file.


Constructor & Destructor Documentation

oaFile::oaFile const oaString &    nameIn [inline]
 

This function constructs an oaFile object associated with the given file name, but does not open the file.

Parameters:
nameIn Path to the file (either a path relative to the current working directory, or an absolute path name).

oaFile::~oaFile   [inline, virtual]
 

This function destroys this oaFile object, closing the file if the file is open, and releasing all resources associated with the file.


Member Function Documentation

void oaFile::close  
 

This function closes the file.

Exceptions:
oacFileCloseFailed 

void oaFile::copyFile const oaString &    srcPath,
const oaString &    dstPath
[static]
 

This function copies the source file to the destination file. The source file must be readable, and the destination file must be writable. If the destination file exists, it will be overwritten.

Parameters:
srcPath absolute or relative path, including file name, of the source file
dstPath absolute or relative path, including file name, of the destination file
Exceptions:
oacFileCopyFailed 
oacFileSetAttrFailed 

oaBoolean oaFile::exists   const [virtual]
 

This function returns a boolean value that indicates if this file exists on disk.

Reimplemented from oaFSComponent.

void oaFile::flush  
 

This function flushes any buffered output to disk.

oaTime oaFile::getCreateTime   const
 

This function returns the creation time of the file on the disk. The format of the time is unit of seconds from Jan, 1, 1970, 0 hour, 0 min, 0 sec.

Exceptions:
oacFileGetInfoFailed 

oaTime oaFile::getLastWriteTime   const
 

This function returns the last modified time of the file of the file on the disk (the last time the file was written).

Exceptions:
oacFileGetInfoFailed 

const char * oaFile::getMode   const [inline]
 

This function returns a string containing the current mode used to access this file.

oaUInt8 oaFile::getSize   const
 

This function returns the size of this file, in bytes.

Exceptions:
oacFileGetInfoFailed 

oaBoolean oaFile::isNonEmpty   const
 

This function returns true if this file exists on disk and the size is > 0. This function is provided for efficiency so that the file does not have to be looked up twice.

oaBoolean oaFile::isOpen   const
 

This function returns true if this file is open.

void oaFile::open oaChar    modeIn
 

This function opens this file using the specified access mode.

Parameters:
modeIn The mode in which to open the file
  • 'r' for read
  • 'w' for write
  • 'a' for append
Exceptions:
oacInvalidFileAccessMode 
oacFileOpenFailed 

oaUInt4 oaFile::read void *    data,
oaUInt4    numBytes
 

This function reads data from the file. The file must be open in a readable mode. The function returns the actual number of bytes read, which may be less than the number of bytes requested. An exception will be thrown if any IO error occurs.

Parameters:
data The buffer that this function will fill in with the bytes read
numBytes The number of bytes requested
Exceptions:
oacFileReadFailed 

oaUInt4 oaFile::write void *    data,
oaUInt4    numBytes
 

This function writes the data to the file. The file must be open in a writable mode. An exception will be thrown if any IO error occurs.

Parameters:
data The buffer containing the bytes to be written
numBytes The number of bytes to write
Exceptions:
oacFileWriteFailed 


The documentation for this class was generated from the following files:

Return to top of page