#include <StreamingArchiveFile.h>
Inherits RAMFile.
Public Member Functions | |
| StreamingArchiveFile () | |
| virtual Bool | open (const Char *filename, Int access=0) |
| Open a file for access. | |
| virtual void | close (void) |
| Close the file. | |
| virtual Int | read (void *buffer, Int bytes) |
| Read the specified number of bytes in to buffer: See File::read. | |
| virtual Int | write (const void *buffer, Int bytes) |
| Write the specified number of bytes from the buffer: See File::write. | |
| virtual Int | seek (Int new_pos, seekMode mode=CURRENT) |
| Set file position: See File::seek. | |
| virtual void | nextLine (Char *buf=NULL, Int bufSize=0) |
| moves current position to after the next new-line | |
| virtual Bool | scanInt (Int &newInt) |
| return what gets read as an integer from the current memory position. | |
| virtual Bool | scanReal (Real &newReal) |
| return what gets read as a float from the current memory position. | |
| virtual Bool | scanString (AsciiString &newString) |
| return what gets read as a string from the current memory position. | |
| virtual Bool | open (File *file) |
| Open file for fast RAM access. | |
| virtual Bool | openFromArchive (File *archiveFile, const AsciiString &filename, Int offset, Int size) |
| copy file data from the given file at the given offset for the given size. | |
| virtual Bool | copyDataToFile (File *localFile) |
| write the contents of the RAM file to the given local file. This could be REALLY slow. | |
| virtual char * | readEntireAndClose () |
| virtual File * | convertToRAMFile () |
Public Member Functions inherited from RAMFile | |
| RAMFile () | |
| RAMFile () | |
| virtual | ~RAMFile () |
| virtual Int | write (void *buffer, Int bytes) |
| Write the specified number of bytes from the buffer: See File::write. | |
| Bool | open (File *file) |
| Open file for fast RAM access. | |
Public Member Functions inherited from File | |
| Bool | eof () |
| virtual Bool | print (const Char *format,...) |
| Prints formated string to text file. | |
| virtual Int | size (void) |
| Returns the size of the file. | |
| virtual Int | position (void) |
| Returns the current read/write position. | |
| void | setName (const char *name) |
| Set the name of the file. | |
| const char * | getName (void) const |
| Returns a pointer to the name of the file. | |
| Int | getAccess (void) const |
| Returns file's access flags. | |
| void | deleteOnClose (void) |
| Causes the File object to delete itself when it closes. | |
| virtual Bool | printf (const Char *format,...) |
| Prints formated string to text file. | |
| virtual Int | size (void) |
| Returns the size of the file. | |
| virtual Int | position (void) |
| Returns the current read/write position. | |
| void | setName (const Char *name) |
| Set the name of the file. | |
| Char * | getName (void) |
| Returns a pointer to the name of the file. | |
| Bool | getName (Char *buffer, Int max) |
| Copies the name of the file to the buffer. | |
| Int | getAccess (void) |
| Returns file's access flags. | |
| void | deleteOnClose (void) |
| Causes the File object to delete itself when it closes. | |
| File () | |
| Default constructor - Create an unassociated File. | |
| File (const Char *name, ERights rights=Rights_ReadOnly) | |
| Name constructor - Create a File with an associated name. | |
| File (const UString &name, ERights rights=Rights_ReadOnly) | |
| virtual | ~File () |
| Destructor. | |
| const UString & | GetName (void) const |
| Retrieve name of file. | |
| virtual void | SetName (const UString &name) |
| Associate a name to the file. | |
| virtual ERights | GetRights (void) const |
| Retrieve file access rights. | |
| virtual void | SetRights (ERights rights) |
| Set file access rights. | |
| virtual bool | IsAvailable (bool force=false) |
| Check if the file is available. | |
| virtual bool | IsOpen (void) const |
| Check if te file is open. | |
| virtual EFileError | Open (ERights rights) |
| Open the file for access. | |
| virtual EFileError | Open (const UString &name, ERights rights) |
| Open the file with the associated name for access. | |
| virtual void | Close (void) |
| Close the file. | |
| virtual EFileError | Create (void) |
| Create a new file. | |
| virtual EFileError | Delete (void) |
| Delete an existing file. | |
| virtual EFileError | Load (void *&outBuffer, UInt32 &outSize) |
| Load the file into memory. | |
| virtual EFileError | Save (const void *buffer, UInt32 size) |
| Write file data. | |
| virtual bool | OnFileError (EFileError error, bool canRetry) |
| Error handling hook. | |
| virtual UInt32 | GetLength (void) |
| Get the length of the file. | |
| virtual void | SetLength (UInt32 length) |
| Set the length of the file. | |
| virtual UInt32 | GetMarker (void) |
| Get file position marker. | |
| virtual void | SetMarker (Int32 offset, EStreamFrom from) |
| Set file position marker. | |
| virtual bool | AtEnd (void) |
| End of file test. | |
| virtual UInt32 | GetBytes (void *ptr, UInt32 bytes) |
| Read bytes from the file. | |
| virtual UInt32 | PutBytes (const void *ptr, UInt32 bytes) |
| Write bytes to the file. | |
| virtual UInt32 | PeekBytes (void *ptr, UInt32 bytes) |
| Read bytes from the file without marker adjustment. | |
| virtual void | Flush (void) |
| Flush the stream. | |
Public Member Functions inherited from MemoryPoolObject | |
| void | deleteInstance () |
Protected Attributes | |
| File * | m_file |
| The archive file that I came from. | |
| Int | m_startingPos |
| My starting position in the archive. | |
| Int | m_size |
| My length. | |
| Int | m_curPos |
| My current position. | |
Protected Attributes inherited from RAMFile | |
| Char * | m_data |
| File data in memory. | |
| Int | m_pos |
| current read position | |
| Int | m_size |
| size of file in memory | |
Protected Attributes inherited from File | |
| AsciiString | m_nameStr |
| Stores file name. | |
| Int | m_access |
| How the file was opened. | |
| Bool | m_open |
| Has the file been opened. | |
| Bool | m_deleteOnClose |
| delete File object on close() | |
| Char | m_name [IO_MAX_PATH+1] |
| Stores file name. | |
Additional Inherited Members | |
Public Types inherited from File | |
| enum | access { NONE = 0x00000000 , READ = 0x00000001 , WRITE = 0x00000002 , APPEND = 0x00000004 , CREATE = 0x00000008 , TRUNCATE = 0x00000010 , TEXT = 0x00000020 , BINARY = 0x00000040 , READWRITE = (READ | WRITE) , ONLYNEW = 0x00000080 , STREAMING = 0x00000100 , NONE = 0x00000000 , READ = 0x00000001 , WRITE = 0x00000002 , APPEND = 0x00000004 , CREATE = 0x00000008 , TRUNCATE = 0x00000010 , TEXT = 0x00000020 , BINARY = 0x00000040 , READWRITE = (READ | WRITE) , NEW = 0x00000080 } |
| enum | seekMode { START , CURRENT , END , START , CURRENT , END } |
| enum | access { NONE = 0x00000000 , READ = 0x00000001 , WRITE = 0x00000002 , APPEND = 0x00000004 , CREATE = 0x00000008 , TRUNCATE = 0x00000010 , TEXT = 0x00000020 , BINARY = 0x00000040 , READWRITE = (READ | WRITE) , ONLYNEW = 0x00000080 , STREAMING = 0x00000100 , NONE = 0x00000000 , READ = 0x00000001 , WRITE = 0x00000002 , APPEND = 0x00000004 , CREATE = 0x00000008 , TRUNCATE = 0x00000010 , TEXT = 0x00000020 , BINARY = 0x00000040 , READWRITE = (READ | WRITE) , NEW = 0x00000080 } |
| enum | seekMode { START , CURRENT , END , START , CURRENT , END } |
| enum | EFileError { FileError_None = 0 , FileError_FNF , FileError_Access , FileError_Open , FileError_Read , FileError_Write , FileError_Seek , FileError_Nomem , FileError_Fault } |
Public Types inherited from Stream | |
| enum | EStreamFrom { FromStart = 0 , FromMarker , FromEnd } |
Protected Member Functions inherited from File | |
| File () | |
| This class can only used as a base class. | |
| File () | |
| This class can only used as a base class. | |
| virtual | ~File () |
Protected Member Functions inherited from MemoryPoolObject | |
| virtual | ~MemoryPoolObject () |
| void * | operator new (size_t s) |
| void | operator delete (void *p) |
| virtual MemoryPool * | getObjectMemoryPool ()=0 |
File abstraction for standard C file operators: open, close, lseek, read, write
Definition at line 75 of file StreamingArchiveFile.h.
| StreamingArchiveFile::StreamingArchiveFile | ( | ) |
Definition at line 106 of file StreamingArchiveFile.cpp.
|
virtual |
Close the file.
Closes the current file if it is open. Must call StreamingArchiveFile::close() for each successful StreamingArchiveFile::open() call.
Reimplemented from RAMFile.
Definition at line 207 of file StreamingArchiveFile.cpp.
|
inlinevirtual |
Reimplemented from RAMFile.
Definition at line 108 of file StreamingArchiveFile.h.
write the contents of the RAM file to the given local file. This could be REALLY slow.
Reimplemented from RAMFile.
Definition at line 105 of file StreamingArchiveFile.h.
moves current position to after the next new-line
Reimplemented from RAMFile.
Definition at line 98 of file StreamingArchiveFile.h.
Open a file for access.
This function opens a file using the standard C open() call. Access flags are mapped to the appropriate open flags. Returns true if file was opened successfully.
Reimplemented from RAMFile.
Definition at line 141 of file StreamingArchiveFile.cpp.
Open file for fast RAM access.
Reimplemented from RAMFile.
Definition at line 158 of file StreamingArchiveFile.cpp.
|
virtual |
copy file data from the given file at the given offset for the given size.
Reimplemented from RAMFile.
Definition at line 166 of file StreamingArchiveFile.cpp.
Read the specified number of bytes in to buffer: See File::read.
Reimplemented from RAMFile.
Definition at line 216 of file StreamingArchiveFile.cpp.
|
inlinevirtual |
Allocate a buffer large enough to hold entire file, read the entire file into the buffer, then close the file. the buffer is owned by the caller, who is responsible for freeing is (via delete[]). This is a Good Thing to use because it minimizes memory copies for BIG files.
Reimplemented from RAMFile.
Definition at line 107 of file StreamingArchiveFile.h.
return what gets read as an integer from the current memory position.
Reimplemented from RAMFile.
Definition at line 99 of file StreamingArchiveFile.h.
return what gets read as a float from the current memory position.
Reimplemented from RAMFile.
Definition at line 100 of file StreamingArchiveFile.h.
|
inlinevirtual |
return what gets read as a string from the current memory position.
Reimplemented from RAMFile.
Definition at line 101 of file StreamingArchiveFile.h.
Set file position: See File::seek.
Reimplemented from RAMFile.
Definition at line 250 of file StreamingArchiveFile.cpp.
Write the specified number of bytes from the buffer: See File::write.
Reimplemented from RAMFile.
Definition at line 240 of file StreamingArchiveFile.cpp.
|
protected |
My current position.
Definition at line 83 of file StreamingArchiveFile.h.
|
protected |
The archive file that I came from.
Definition at line 80 of file StreamingArchiveFile.h.
|
protected |
My length.
Definition at line 82 of file StreamingArchiveFile.h.
|
protected |
My starting position in the archive.
Definition at line 81 of file StreamingArchiveFile.h.