MarSTDv2004: CFile Class Reference

MarSTDv2004

CFile Class Reference

List of all members.

Detailed Description

FILE* wrapper. Closes file automatically when leaving scope. Also adds cleaner reading and writing functions as well as formatted text outputting.
// Example:

bool print_file_info(char* filename) {

        CFile file;
        if (!file.open(filename, "rb"))
                return false;
                
        printf("size: %d", file.size());
        
        char c;
        if (file.read(&c, 1))
                printf("%c", c);
                
        printf("position: %d", file.position());
        
        return true;

}

Definition at line 52 of file CFile.h.

Public Member Functions

bool open (char *fn, char *mode)
void close ()
bool opened ()
bool read (void *p, unsigned int size)
bool write (void *p, unsigned int size)
bool printf (char *format,...)
unsigned long position ()
bool seek (unsigned long position)
int size ()

Protected Attributes

FILE * f
 File handle.

Member Function Documentation

bool CFile::open char *  fn,
char *  mode
 

Same as fopen(fn, mode).

Parameters:
fn Filename of the file to open.
mode Mode to open file with. See the description of fopen for a list of possible options.
Returns:
Return true on succes, false otherwise.

Definition at line 78 of file CFile.h.

Here is the call graph for this function:

void CFile::close  ) 
 

Same as fclose(f).

Definition at line 88 of file CFile.h.

Here is the call graph for this function:

bool CFile::opened  ) 
 

Returns true if the file is opened.

Returns:
Return true on succes, false otherwise.

Definition at line 99 of file CFile.h.

bool CFile::read void *  p,
unsigned int  size
 

Reads size bytes from file to p.

Parameters:
p Pointer to beginning of data.
size Size of the data chunk to write in bytes.
Returns:
Return true on succes, false otherwise.

Definition at line 112 of file CFile.h.

Here is the call graph for this function:

bool CFile::write void *  p,
unsigned int  size
 

Writes size bytes to file from p.

Parameters:
p Address of target location.
size The number of bytes to read from the file.
Returns:
Return true on succes, false otherwise.

Definition at line 125 of file CFile.h.

Here is the call graph for this function:

bool CFile::printf char *  format,
  ...
 

Writes formatted text to file. Same as regular printf(...).

Parameters:
format Text to print with regular special x characters. See documentation of printf.
... Variable sized argument list. See printf.
Returns:
Return true on success, false otherwise.

Definition at line 138 of file CFile.h.

Here is the call graph for this function:

unsigned long CFile::position  ) 
 

Returns the file position in bytes.

Returns:
The file position in bytes.

Definition at line 156 of file CFile.h.

Here is the call graph for this function:

bool CFile::seek unsigned long  position  ) 
 

Seeks position bytes from the beginning of the file.

Parameters:
position The position in bytes from the beginning of the file to seek to.
Returns:
Returns true on succes, false otherwise.

Definition at line 167 of file CFile.h.

Here is the call graph for this function:

int CFile::size  ) 
 

Returns the size of the file in bytes.

Returns:
The size of the file in bytes.

Definition at line 179 of file CFile.h.

Here is the call graph for this function:


The documentation for this class was generated from the following file:
Generated on Tue Feb 8 21:59:37 2005 for MarSTDv2004 by  doxygen 1.4.1