Clarisse 5.0 SP8 SDK  5.0.5.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SysFile Class Reference
Inheritance diagram for SysFile:
SysFileBuffer

Public Types

enum  Type {
  FILE_TYPE_ASCII,
  FILE_TYPE_BINARY,
  FILE_TYPE_COUNT
}
 
enum  Mode {
  FILE_MODE_READ,
  FILE_MODE_WRITE,
  FILE_MODE_READWRITE,
  FILE_MODE_APPEND,
  FILE_MODE_COUNT
}
 

Public Member Functions

 SysFile ()
 Constructor, do not open file.
 
 SysFile (const CoreString &filename, const Mode &mode=FILE_MODE_READ, const Type &type=FILE_TYPE_BINARY)
 Constructor which constructs and opens file.
 
virtual ~SysFile ()
 Destructor. Closes the file if needed.
 
bool open (const CoreString &filename, const Mode &mode=FILE_MODE_READ, const Type &type=FILE_TYPE_BINARY)
 Opens file.
 
void close ()
 Closes file.
 
virtual bool skip (const long long &bytes)
 Move forward in current opened file from a amount of bytes.
 
virtual long long read (CoreString &str, const long long &count) const
 Reads data from file in incoming buffer.
 
virtual long long read (void *data, const long long &element_size, const long long &count) const
 Reads data from file in incoming buffer.
 
long long write_line (const char *buffer, const long long &buffer_size)
 write text data into file.
 
long long write_line (const CoreString &str)
 write text data into file.
 
long long write (const char *buffer, const long long &count) const
 write data into file.
 
long long write (const CoreString &str) const
 write data into file.
 
long long write (void *data, const long long &element_size, const long long &count) const
 write data into file.
 
long long write_fmt (const char *fmt,...) const
 write data into file with varying params
 
virtual void set_position (const long long &position)
 Changes file position to incoming position.
 
const long long & get_position () const
 Returns current file position.
 
virtual bool is_eof () const
 Returns true if position is at the end of file. Returns also true if no file is currently opened.
 
bool is_opened () const
 returns true if a file is currently opened, false otherwise.
 
const Mode & get_mode () const
 returns file opening mode
 
const Type & get_type () const
 returns file opening type
 
const CoreStringget_filename () const
 returns filename
 
const long long & get_size () const
 returns file size
 
bool flush ()
 

Static Public Member Functions

static CoreString get_type_name (const Type &type)
 
static CoreString get_mode_name (const Mode &mode)
 

Protected Member Functions

virtual long long read (char *buffer, const long long &count) const
 Reads data from file in incoming buffer. Adds '\0' character at the end.
 

Protected Attributes

void * m_file
 The FILE *. Stored as void * to avoid including stdio.h in our headers.
 
long long m_position
 

Constructor & Destructor Documentation

SysFile::SysFile ( const CoreString filename,
const Mode &  mode = FILE_MODE_READ,
const Type &  type = FILE_TYPE_BINARY 
)
explicit

Constructor which constructs and opens file.

Parameters
[in]filenamefile location
[in]modefile opening mode (READ, WRITE, APPEND)
[in]typefile type (ASCII or BINARY)

Member Function Documentation

bool SysFile::open ( const CoreString filename,
const Mode &  mode = FILE_MODE_READ,
const Type &  type = FILE_TYPE_BINARY 
)

Opens file.

Parameters
[in]filenamefile location
[in]modefile opening mode (READ, WRITE, APPEND)
[in]typefile type (ASCII or BINARY)
Returns
true if file opening was successful, false otherwise
long long SysFile::read ( CoreString str,
const long long &  count 
) const
virtual

Reads data from file in incoming buffer.

Parameters
[in]strstring tp to read in
[in]numberof bytes to read
Returns
read bytes count
long long SysFile::read ( void *  data,
const long long &  element_size,
const long long &  count 
) const
virtual

Reads data from file in incoming buffer.

Parameters
[in]bufferpre-allocated buffer to read in
[in]sizeof element to read
[in]numberof elements to read
Returns
number of elements read

Reimplemented in SysFileBuffer.

long long SysFile::read ( char *  buffer,
const long long &  count 
) const
protectedvirtual

Reads data from file in incoming buffer. Adds '\0' character at the end.

Parameters
[in]bufferpre-allocated buffer to read in. It must be large enough to contain count+1 (for ending '\0' character).
[in]numberof bytes to read.
Returns
read bytes count
bool SysFile::skip ( const long long &  bytes)
virtual

Move forward in current opened file from a amount of bytes.

Parameters
[in]bytesamount of bytes to move forward. If bytes would make the position after end of file, we position to end of file.

Reimplemented in SysFileBuffer.

long long SysFile::write ( const char *  buffer,
const long long &  count 
) const

write data into file.

Parameters
[in]bufferbuffer to write
[in]buffer_sizebuffer length to write
Returns
number of written characters
long long SysFile::write ( const CoreString str) const

write data into file.

Parameters
[in]bufferstring to write
Returns
number of written characters
long long SysFile::write ( void *  data,
const long long &  element_size,
const long long &  count 
) const

write data into file.

Parameters
[in]databuffer to write
[in]element_sizesize of one buffer element
[in]countelement count to write
Returns
number of written characters
long long SysFile::write_fmt ( const char *  fmt,
  ... 
) const

write data into file with varying params

Parameters
[in]fmtfollowing arguments desc
[in]...following arguments
Returns
number of written characters
long long SysFile::write_line ( const char *  buffer,
const long long &  buffer_size 
)

write text data into file.

Parameters
[in]bufferbuffer to write
[in]buffer_sizebuffer length to write
Returns
number of written characters
long long SysFile::write_line ( const CoreString str)

write text data into file.

Parameters
[in]bufferstring to write
Returns
number of written characters