Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
Public Member Functions | Private Member Functions | Private Attributes
platform::File Class Reference

Class for accessing a file on disk. More...

#include <File.h>

List of all members.

Public Member Functions

void close ()
bool eof ()
 returns if file is at the end position
 File (const std::string &fileName, u32 fileAccess=FA_READ|FA_WRITE)
void flush ()
 flush any buffers by writing to the file.
const std::string & getFileName ()
 returns name of file
u32 getPos ()
 returns where in the file we are.
bool opened ()
 returns if file is open
u32 read (void *buffer, u32 size, u32 count)
u32 read (void *buffer, u32 size)
 returns how much was read
u32 read (std::string &str)
u32 readLine (std::string &line)
bool seek (s32 finalPos, bool relativeMovement=false)
u32 size ()
 returns size of file.
u32 tell () const
 returns the number of bytes from the beginning of the file.
bool write (const c8 *str)
bool write (const std::string &str)
u32 write (const void *buffer, u32 size, u32 count)
u32 write (const void *buffer, u32 size)
 writes an amount of bytes to the file.
bool writeLine (const std::string &line)
 Writes a line to the file.
 ~File ()

Private Member Functions

void openFile ()
 opens the file

Private Attributes

u32 mAccessMode
FILE * mFile
std::string mFileName

Detailed Description

Class for accessing a file on disk.


Constructor & Destructor Documentation

platform::File::File ( const std::string &  fileName,
u32  fileAccess = FA_READ | FA_WRITE 
)

References mAccessMode, mFileName, and openFile().

platform::File::~File ( )

References close().


Member Function Documentation

void platform::File::close ( )

References mFile.

Referenced by ~File().

bool platform::File::eof ( )

returns if file is at the end position

References mFile.

Referenced by resource::FileDataStream::eof().

void platform::File::flush ( )

flush any buffers by writing to the file.

References mFile.

const std::string & platform::File::getFileName ( )

returns name of file

References mFileName.

u32 platform::File::getPos ( )

returns where in the file we are.

References mFile.

Referenced by size().

bool platform::File::opened ( )

returns if file is open

References mFile.

Referenced by resource::FileDataStream::FileDataStream().

void platform::File::openFile ( ) [private]
u32 platform::File::read ( std::string &  str)

Reads the entire contents of a file into a single string.

Parameters:
str,:String to read the file's data into. return Returns how many bytes were read.

References platform::FA_READ, mAccessMode, mFile, and size().

u32 platform::File::read ( void *  buffer,
u32  size 
)

returns how much was read

References platform::FA_READ, mAccessMode, and mFile.

Referenced by resource::FileDataStream::read().

u32 platform::File::read ( void *  buffer,
u32  size,
u32  count 
)

References platform::FA_READ, mAccessMode, and mFile.

u32 platform::File::readLine ( std::string &  line)

Reads a line from the file.

Parameters:
line,:Pointer to buffer where the line will be written to. return Returns how many bytes were read.

References platform::FA_READ, mAccessMode, mFile, and size().

bool platform::File::seek ( s32  finalPos,
bool  relativeMovement = false 
)

changes position in file, returns true if successful. if relativeMovement==true, the pos is changed relative to current pos, otherwise from begin of file.

References mFile.

Referenced by resource::FileDataStream::seek(), and resource::FileDataStream::skip().

u32 platform::File::size ( )

returns size of file.

References getPos(), and mFile.

Referenced by resource::FileDataStream::FileDataStream(), read(), and readLine().

u32 platform::File::tell ( ) const

returns the number of bytes from the beginning of the file.

References mFile.

Referenced by resource::FileDataStream::tell().

u32 platform::File::write ( const void *  buffer,
u32  size,
u32  count 
)
bool platform::File::write ( const c8 str)

writes a string to file. returns true on success.

References platform::FA_APPEND, platform::FA_WRITE, mAccessMode, and mFile.

u32 platform::File::write ( const void *  buffer,
u32  size 
)

writes an amount of bytes to the file.

References platform::FA_APPEND, platform::FA_WRITE, mAccessMode, and mFile.

Referenced by resource::Serializer::writeData().

bool platform::File::write ( const std::string &  str)
bool platform::File::writeLine ( const std::string &  line)

Writes a line to the file.

References platform::FA_APPEND, platform::FA_WRITE, mAccessMode, and mFile.

Referenced by resource::Serializer::writeString().


Member Data Documentation

FILE* platform::File::mFile [private]
std::string platform::File::mFileName [private]

Referenced by File(), getFileName(), and openFile().


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

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:08 by Doxygen (1.7.4)