Classes | Public Member Functions | Static Public Member Functions

xl7::io::PacketFile Class Reference

#include <PacketFile.h>

Inheritance diagram for xl7::io::PacketFile:
xl7::io::IFile xl7::io::IRom

List of all members.

Classes

struct  Header
struct  InfoBlock

Public Member Functions

 PacketFile (void)
 ~PacketFile (void)
bool IsOpen () const
OpenFlags GetOpenFlags () const
unsigned GetSize () const
bool SetSize (unsigned size)
unsigned GetPointer () const
unsigned SetPointer (unsigned pointer)
bool Create (const cl7::string_type &file_name)
bool Create (const cl7::string_type &file_name, const cl7::string_type &password)
bool Init (const cl7::string_type &file_name)
bool Init (const cl7::string_type &file_name, const cl7::string_type &password)
bool Open (const cl7::string_type &file_name)
bool Open (const cl7::string_type &file_name, const OpenFlags flags)
bool Open ()
bool Open (const OpenFlags flags)
bool Close ()
unsigned Read (void *buffer, unsigned bytes)
unsigned Write (const void *buffer, unsigned bytes)
unsigned Seek (signed bytes, const SeekFlags from=current)
unsigned long Find (const cl7::string_type &file_name) const
bool Add (void *buffer, unsigned bytes, const cl7::string_type &file_name)
bool Insert (void *buffer, unsigned bytes, const cl7::string_type &file_name, unsigned long index)
bool Remove (unsigned long index)
bool MoveTo (unsigned long index_src, unsigned long index_dst)
void _Reset ()
void _CleanUp ()
bool _CheckIsOpen () const
bool _CheckIsOpen (const cl7::string_type &file_name) const
bool _ReadHeader (const cl7::string_type &password)
bool _WriteHeader (const cl7::string_type &password)
bool _ReadInfoBlocks ()
bool _WriteInfoBlockAndData (unsigned long i, unsigned long offset, void *buffer, unsigned bytes)
unsigned long _GetInfoBlockAndDataLength (unsigned bytes, const cl7::string_type &file_name)
unsigned long _GetInfoBlockAndDataLength (unsigned long i)

Static Public Member Functions

static unsigned long _Align4Byte (unsigned long offset)

Constructor & Destructor Documentation

xl7::io::PacketFile::PacketFile ( void   ) 

Default constructor.

xl7::io::PacketFile::~PacketFile ( void   ) 

Destructor.


Member Function Documentation

static unsigned long xl7::io::PacketFile::_Align4Byte ( unsigned long  offset  )  [inline, static]

Adjusts the given offset, so it is 4-byte-aligned.

bool xl7::io::PacketFile::_CheckIsOpen (  )  const

Checks if the packet file is open and, if not, fires a message.

bool xl7::io::PacketFile::_CheckIsOpen ( const cl7::string_type file_name  )  const

Checks if the given file is open and, if not, fires a message.

void xl7::io::PacketFile::_CleanUp (  ) 

Closes the eventually open file and frees up allocated memory.

unsigned long xl7::io::PacketFile::_GetInfoBlockAndDataLength ( unsigned  bytes,
const cl7::string_type file_name 
)

Returns the length, in bytes, a new file of the given length and file name would need within this packet file. The function takes the info block, the file name, the data itself as well as any byte paddings into consideration.

unsigned long xl7::io::PacketFile::_GetInfoBlockAndDataLength ( unsigned long  i  ) 

Returns the length, in bytes, the i-th file needs within this packet file. The function takes the info block, the file name, the data itself as well as any byte paddings into consideration.

bool xl7::io::PacketFile::_ReadHeader ( const cl7::string_type password  ) 

Seeks to the beginning of the packet file and reads its header. On success, the function returns true. If the header cannot be read or the header contains bad data, the function returns false.

bool xl7::io::PacketFile::_ReadInfoBlocks (  ) 

Steps through the packet file and reads all the info blocks (and file names). On success, the function returns true. If the one of the info block cannot be read or contains bad data, the function returns false.

Steps through the packet file and reads all the info blocks (and file names).

void xl7::io::PacketFile::_Reset (  ) 

Pre-allocates memory to be used soon and/or clears the internal lists.

bool xl7::io::PacketFile::_WriteHeader ( const cl7::string_type password  ) 

Seeks to the beginning of the packet file and writes its header. On success, the function returns true. If the header cannot be written, the function returns false.

bool xl7::io::PacketFile::_WriteInfoBlockAndData ( unsigned long  i,
unsigned long  offset,
void *  buffer,
unsigned  bytes 
)

Writes the i-th info block (and file name) to the packet file at the given offset. Additionally, the given data with the given length of the particular file will be written to the packet file. On success, the function returns true. If the info block or the file data cannot be written, the function returns false.

bool xl7::io::PacketFile::Add ( void *  buffer,
unsigned  bytes,
const cl7::string_type file_name 
)

Adds a file to this packet file. The "file" is given only by its data (buffer and length, in bytes) and a file name. The file will be inserted at the end of this packet file. On success, the function returns true, false otherwise.

bool xl7::io::PacketFile::Close (  )  [virtual]

Closes the file.

Implements xl7::io::IRom.

bool xl7::io::PacketFile::Create ( const cl7::string_type file_name,
const cl7::string_type password 
)

Initializes this packet file by newly creating it in the file system. The new packet file will be password protected by the given password.

bool xl7::io::PacketFile::Create ( const cl7::string_type file_name  ) 

Initializes this packet file by newly creating it in the file system.

unsigned long xl7::io::PacketFile::Find ( const cl7::string_type file_name  )  const

Searches for a file with the given file name and returns its index within this packet file, if found, otherwise -1.

OpenFlags xl7::io::PacketFile::GetOpenFlags (  )  const [inline, virtual]

Returns the flags the file was opened with.

Implements xl7::io::IFile.

unsigned xl7::io::PacketFile::GetPointer (  )  const [virtual]

Returns the current byte position to read or write data.

Implements xl7::io::IRom.

unsigned xl7::io::PacketFile::GetSize (  )  const [virtual]

Returns the size of the file, in bytes.

Implements xl7::io::IRom.

bool xl7::io::PacketFile::Init ( const cl7::string_type file_name  ) 

Initializes this packet file by loading it from the file system.

bool xl7::io::PacketFile::Init ( const cl7::string_type file_name,
const cl7::string_type password 
)

Initializes this packet file by loading it from the file system. The packet will be assumed to be password protected by the given password.

bool xl7::io::PacketFile::Insert ( void *  buffer,
unsigned  bytes,
const cl7::string_type file_name,
unsigned long  index 
)

Adds a file to this packet file. The "file" is given only by its data (buffer and length, in bytes) and a file name. The file will be inserted at the specified index position within this packet file. On success, the function returns true, false otherwise.

bool xl7::io::PacketFile::IsOpen (  )  const [inline, virtual]

Checks whether the file is open and can be read.

Implements xl7::io::IRom.

bool xl7::io::PacketFile::MoveTo ( unsigned long  index_src,
unsigned long  index_dst 
)

Moves the file with the given index to the specified index position within this packet file. On success, the function returns true, false otherwise.

bool xl7::io::PacketFile::Open ( const cl7::string_type file_name,
const OpenFlags  flags 
)

Opens the file for reading or writing.

bool xl7::io::PacketFile::Open (  )  [virtual]

Re-opens the file for reading. Ensure that you have already opened the file earlier (see Init).

Implements xl7::io::IRom.

bool xl7::io::PacketFile::Open ( const OpenFlags  flags  )  [virtual]

Re-opens the file for reading or writing. Ensure that you have already opened the file earlier (see Init).

Implements xl7::io::IFile.

bool xl7::io::PacketFile::Open ( const cl7::string_type file_name  ) 

Opens the file for reading.

unsigned xl7::io::PacketFile::Read ( void *  buffer,
unsigned  bytes 
) [virtual]

Reads data from the file and returns the number of bytes read.

Implements xl7::io::IRom.

bool xl7::io::PacketFile::Remove ( unsigned long  index  ) 

Removes the file with the given index from this packet file. On success, the function returns true, false otherwise.

unsigned xl7::io::PacketFile::Seek ( signed  bytes,
const SeekFlags  from = current 
) [virtual]

Resets the current byte position to read or write data by moving the pointer by the specified bytes. The function returns the new position.

Implements xl7::io::IRom.

unsigned xl7::io::PacketFile::SetPointer ( unsigned  pointer  )  [virtual]

Resets the current byte position to read or write data. The function returns the new position.

Implements xl7::io::IRom.

bool xl7::io::PacketFile::SetSize ( unsigned  size  )  [virtual]

Sets the size of the file, in bytes. Truncates or appends the difference in bytes.

Implements xl7::io::IFile.

unsigned xl7::io::PacketFile::Write ( const void *  buffer,
unsigned  bytes 
) [virtual]

Writes data to the file and returns the number of bytes written.

Implements xl7::io::IFile.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines