Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

P::File Class Reference
[Core library]

File I/O class. More...

#include <pfile.h>

Inheritance diagram for P::File:

P::IODevice P::FileStream List of all members.

Public Types

enum  openMode_t { Normal, Append, Truncate }
 File open mode. More...

enum  createMode_t { OpenCreate, OpenExisting, CreateFail }
 File creation mode. More...


Public Member Functions

 File () throw ()
 Default constructor.

 File (const File &f) throw (IOError)
 Copy constructor.

 File (const char *path, accessMode_t access, openMode_t open=Normal, createMode_t create=OpenCreate, shareMode_t share=AllowNone) throw (IOError)
 File open constructor.

 ~File () throw ()
 Destructor.

void open (const char *path, accessMode_t access, openMode_t open=Normal, createMode_t create=OpenCreate, shareMode_t share=AllowNone) throw (IOError)
 Open a file.

size_t peek (char *buffer, size_t count) throw (IOError)
 Peek data from file.

void truncate (off_t size) throw (IOError)
 Truncate/extent file to given size.

off_t size () throw (IOError)
 Returns the size of the file.

void reopen () throw (IOError)
 Reopen's the file.

const std::string & path () const throw ()
 Returns the path of the file.

Fileoperator= (const File &f) throw (IOError)

Static Public Member Functions

void unlink (const char *path) throw (IOError)
 Delete file.

bool exists (const char *path) throw ()
 Test if filesystem entry exists.

FileInfo stat (const char *path) throw (IOError)
 Get info about filesystem entry.

File mktemp (const char *prefix) throw (IOError)
 Create temp file.


Detailed Description

File I/O class.

This class can be used to read, write and create objects located in the filesystem. Other operations include unlinking of a object, testing for existence, retrieving filesystem informations and creating a temporary file.

Author:
Christian Prochnow <cproch@seculogix.de>

Definition at line 41 of file pfile.h.


Member Enumeration Documentation

enum P::File::createMode_t
 

File creation mode.

The file creation mode tells File::open() which action to tkae if the file exists, and which action to take when the file does not exist.

Enumeration values:
OpenCreate  Open file create if not existent
OpenExisting  Open existing file, fail if not existent
CreateFail  Create and open file, fail if already existent

Definition at line 64 of file pfile.h.

enum P::File::openMode_t
 

File open mode.

Tells File::open() where to position the file pointer after opening the file.

Enumeration values:
Normal  Normal open - the file pointer is placed at the beginning of the file
Append  Open for appending - the file pointer is placed past the end of the file
Truncate  Truncate the file and place the file pointer at the beginning

Definition at line 49 of file pfile.h.


Constructor & Destructor Documentation

P::File::File  )  throw ()
 

Default constructor.

P::File::File const File f  )  throw (IOError)
 

Copy constructor.

P::File::File const char *  path,
accessMode_t  access,
openMode_t  open = Normal,
createMode_t  create = OpenCreate,
shareMode_t  share = AllowNone
throw (IOError)
 

File open constructor.

This constructor is used to construct and immediatly opening the file via open().

Parameters:
path Path to the object in the filesystem
access Requested access mode
open Opening mode
create Creation mode
share Sharing mode

P::File::~File  )  throw ()
 

Destructor.


Member Function Documentation

bool P::File::exists const char *  path  )  throw () [static]
 

Test if filesystem entry exists.

File P::File::mktemp const char *  prefix  )  throw (IOError) [static]
 

Create temp file.

void P::File::open const char *  path,
accessMode_t  access,
openMode_t  open = Normal,
createMode_t  create = OpenCreate,
shareMode_t  share = AllowNone
throw (IOError)
 

Open a file.

This method is used to open objects in the filesystem. If another file is currently opened by the object it is closed before opening the new one.

Parameters:
path Path to the object in the filesystem
access Requested access mode
open Opening mode
create Creation mode
share Sharing mode
Exceptions:
IOError 

File& P::File::operator= const File f  )  throw (IOError)
 

const std::string& P::File::path  )  const throw () [inline]
 

Returns the path of the file.

Definition at line 154 of file pfile.h.

size_t P::File::peek char *  buffer,
size_t  count
throw (IOError) [virtual]
 

Peek data from file.

This method can be used to read data from a file without modifying the current file position pointer.

Parameters:
buffer Buffer where data should be placed
count Number of bytes to read
Returns:
The number of bytes actually read
Exceptions:
IOError 

Reimplemented from P::IODevice.

void P::File::reopen  )  throw (IOError)
 

Reopen's the file.

off_t P::File::size  )  throw (IOError)
 

Returns the size of the file.

FileInfo P::File::stat const char *  path  )  throw (IOError) [static]
 

Get info about filesystem entry.

void P::File::truncate off_t  size  )  throw (IOError)
 

Truncate/extent file to given size.

Truncates or extents the file to the given size. If the file was smaller then the given size, the new allocated space is filled with zeros. The file pointer is updated to the new size of the file.

Parameters:
size new size of the file

void P::File::unlink const char *  path  )  throw (IOError) [static]
 

Delete file.


The documentation for this class was generated from the following file:
Generated on Fri Mar 12 21:08:33 2004 for P::Classes by doxygen 1.3.3