#include <RAMFile.h>
Inherited by StreamingArchiveFile.
Public Member Functions | |
| RAMFile () | |
| 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 () |
| RAMFile () | |
| virtual | ~RAMFile () |
| 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 (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. | |
| 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 | |
| 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
| RAMFile::RAMFile | ( | ) |
Definition at line 106 of file RAMFile.cpp.
| RAMFile::RAMFile | ( | ) |
|
virtual |
Definition at line 127 of file RAMFile.cpp.
|
virtual |
Close the file.
Closes the current file if it is open. Must call RAMFile::close() for each successful RAMFile::open() call.
Reimplemented from File.
Reimplemented in StreamingArchiveFile.
Definition at line 248 of file RAMFile.cpp.
|
virtual |
|
virtual |
write the contents of the RAM file to the given local file. This could be REALLY slow.
Reimplemented in StreamingArchiveFile.
Definition at line 462 of file RAMFile.cpp.
moves current position to after the next new-line
Implements File.
Reimplemented in StreamingArchiveFile.
Definition at line 427 of file RAMFile.cpp.
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 File.
Reimplemented in StreamingArchiveFile.
Definition at line 148 of file RAMFile.cpp.
Open file for fast RAM access.
Reimplemented in StreamingArchiveFile.
Definition at line 169 of file RAMFile.cpp.
|
virtual |
copy file data from the given file at the given offset for the given size.
Reimplemented in StreamingArchiveFile.
Definition at line 210 of file RAMFile.cpp.
Read the specified number of bytes in to buffer: See File::read.
Reimplemented from File.
Reimplemented in StreamingArchiveFile.
Definition at line 263 of file RAMFile.cpp.
Read the specified number of bytes in to buffer: See File::read.
Reimplemented from File.
Reimplemented in StreamingArchiveFile.
|
virtual |
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.
Implements File.
Reimplemented in StreamingArchiveFile.
Definition at line 493 of file RAMFile.cpp.
return what gets read as an integer from the current memory position.
Implements File.
Reimplemented in StreamingArchiveFile.
Definition at line 339 of file RAMFile.cpp.
return what gets read as a float from the current memory position.
Implements File.
Reimplemented in StreamingArchiveFile.
Definition at line 369 of file RAMFile.cpp.
|
virtual |
return what gets read as a string from the current memory position.
Implements File.
Reimplemented in StreamingArchiveFile.
Definition at line 403 of file RAMFile.cpp.
Set file position: See File::seek.
Reimplemented from File.
Reimplemented in StreamingArchiveFile.
Definition at line 300 of file RAMFile.cpp.
Write the specified number of bytes from the buffer: See File::write.
Reimplemented from File.
Reimplemented in StreamingArchiveFile.
Definition at line 291 of file RAMFile.cpp.
Write the specified number of bytes from the buffer: See File::write.
Reimplemented from File.
Definition at line 246 of file WSYS_RAMFile.cpp.