MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
File_class Class Reference

#include <File.hpp>

Public Member Functions

 File_class ()
 File_class (const char *aFileName, const char *mode="r")
 ~File_class ()
bool open ()
bool open (const char *aFileName, const char *mode)
bool is_open ()
bool remove ()
bool close ()
int read (void *buf, size_t itemSize, size_t nitems) const
int readChar (char *buf, long start, long length) const
int readChar (char *buf)
int write (const void *buf, size_t itemSize, size_t nitems)
int writeChar (const char *buf, long start, long length)
int writeChar (const char *buf)
off_t size () const
const char * getName () const
int flush () const

Static Public Member Functions

static time_t mtime (const char *aFileName)
static bool exists (const char *aFileName)
static off_t size (FILE *f)
static bool rename (const char *currFileName, const char *newFileName)
static bool remove (const char *aFileName)

Detailed Description

This class provides a file abstraction . It has operations to create, read, write and delete a file.

Version
#@
Id:
File.hpp,v 1.5 2002/04/26 13:15:38 ejonore Exp

Definition at line 30 of file File.hpp.

Constructor & Destructor Documentation

File_class::File_class ( )

Default constructor.

Definition at line 64 of file File.cpp.

File_class::File_class ( const char *  aFileName,
const char *  mode = "r" 
)

Creates a new File with the specified filename and file mode. The real file itself will not be created unless open() is called!

To see the available file modes use 'man 3 fopen'.

Parameters
aFileNamea filename.
modethe mode which the file should be opened/created with, default "r".

Definition at line 70 of file File.cpp.

Here is the call graph for this function:

File_class::~File_class ( )

Destructor.

Definition at line 109 of file File.cpp.

Here is the call graph for this function:

Member Function Documentation

bool File_class::close ( void  )

Closes the file, i.e., the FILE descriptor is closed.

Definition at line 123 of file File.cpp.

Here is the caller graph for this function:

bool File_class::exists ( const char *  aFileName)
static

Returns true if the file exist.

Parameters
aFileNamea filename to check.
Returns
true if the file exists.

Definition at line 36 of file File.cpp.

int File_class::flush ( ) const

Flush the buffer.

Returns
0 if successful.

Definition at line 197 of file File.cpp.

Here is the caller graph for this function:

const char * File_class::getName ( ) const

Returns the filename.

Returns
the filename.

Definition at line 191 of file File.cpp.

Here is the caller graph for this function:

bool File_class::is_open ( void  )

Check if the file is open

Returns
true if file is open, false if closed

Definition at line 104 of file File.cpp.

Here is the caller graph for this function:

time_t File_class::mtime ( const char *  aFileName)
static

Returns time for last contents modification of a file.

Parameters
aFileNamea filename to check.
Returns
the time for last contents modificaton of the file.

Definition at line 27 of file File.cpp.

bool File_class::open ( )

Opens/creates the file. If open() fails then 'errno' and perror() should be used to determine the exact failure cause.

Returns
true if successful. Check errno if unsuccessful.

Definition at line 78 of file File.cpp.

Here is the caller graph for this function:

bool File_class::open ( const char *  aFileName,
const char *  mode 
)

Opens/creates the file with the specified name and mode. If open() fails then 'errno' and perror() should be used to determine the exact failure cause.

Parameters
aFileNamethe file to open.
modethe file mode to use.
Returns
true if successful. Check errno if unsuccessful.

Only copy if it's not the same string

Definition at line 84 of file File.cpp.

Here is the call graph for this function:

int File_class::read ( void *  buf,
size_t  itemSize,
size_t  nitems 
) const

Read from the file. See fread() for more info.

Parameters
bufthe buffer to read into.
itemSizethe size of each item.
nitemsread max n number of items.
Returns
0 if successful.

Definition at line 149 of file File.cpp.

int File_class::readChar ( char *  buf,
long  start,
long  length 
) const

Read char from the file. See fread() for more info.

Parameters
bufthe buffer to read into.
startthe start index of the buf.
lengththe length of the buffer.
Returns
0 if successful.

Definition at line 155 of file File.cpp.

Here is the caller graph for this function:

int File_class::readChar ( char *  buf)

Read chars from the file. See fread() for more info.

Parameters
bufthe buffer to read into.
Returns
0 if successful.

Definition at line 161 of file File.cpp.

Here is the call graph for this function:

bool File_class::remove ( const char *  aFileName)
static

Removes/deletes a file.

Parameters
aFileNamethe file to remove.
Returns
true if successful.

Definition at line 59 of file File.cpp.

Here is the call graph for this function:

bool File_class::remove ( void  )

Removes the file.

Returns
true if successful.

Definition at line 115 of file File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool File_class::rename ( const char *  currFileName,
const char *  newFileName 
)
static

Renames a file.

Parameters
currFileNamethe current name of the file.
newFileNamethe new name of the file.
Returns
true if successful.

Definition at line 54 of file File.cpp.

off_t File_class::size ( FILE *  f)
static

Returns the size of a file.

Parameters
fa pointer to a FILE descriptor.
Returns
the size of the file.

Definition at line 45 of file File.cpp.

off_t File_class::size ( void  ) const

Returns the file size.

Returns
the file size.

Definition at line 185 of file File.cpp.

int File_class::write ( const void *  buf,
size_t  itemSize,
size_t  nitems 
)

Write to file. See fwrite() for more info.

Parameters
bufthe buffer to read from.
itemSizethe size of each item.
nitemswrite max n number of items.
Returns
0 if successful.

Definition at line 167 of file File.cpp.

int File_class::writeChar ( const char *  buf,
long  start,
long  length 
)

Write chars to file. See fwrite() for more info.

Parameters
bufthe buffer to read from.
startthe start index of the buf.
lengththe length of the buffer.
Returns
0 if successful.

Definition at line 173 of file File.cpp.

Here is the caller graph for this function:

int File_class::writeChar ( const char *  buf)

Write chars to file. See fwrite() for more info.

Parameters
bufthe buffer to read from.
Returns
0 if successful.

Definition at line 179 of file File.cpp.

Here is the call graph for this function:


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