Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
LocalFile Class Reference

#include <LocalFile.h>

Inherits File.

Inherited by Win32LocalFile.

Public Member Functions

 LocalFile ()
 
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 file position to after the next new-line
 
virtual Bool scanInt (Int &newInt)
 return what gets read in as an integer at the current file position.
 
virtual Bool scanReal (Real &newReal)
 return what gets read in as a float at the current file position.
 
virtual Bool scanString (AsciiString &newString)
 return what gets read in as a string at the current file position.
 
virtual char * readEntireAndClose ()
 
virtual FileconvertToRAMFile ()
 
- 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 Int write (void *buffer, Int bytes)
 
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.
 
ChargetName (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 UStringGetName (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 ()
 

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 MemoryPoolgetObjectMemoryPool ()=0
 
- 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.
 

Detailed Description

File abstraction for standard C file operators: open, close, lseek, read, write

Definition at line 83 of file LocalFile.h.

Constructor & Destructor Documentation

◆ LocalFile()

LocalFile::LocalFile ( )

Definition at line 114 of file LocalFile.cpp.

Member Function Documentation

◆ close()

void LocalFile::close ( void )
virtual

Close the file.

Closes the current file if it is open. Must call LocalFile::close() for each successful LocalFile::open() call.

Reimplemented from File.

Definition at line 307 of file LocalFile.cpp.

◆ convertToRAMFile()

File * LocalFile::convertToRAMFile ( )
virtual

Implements File.

Definition at line 582 of file LocalFile.cpp.

◆ nextLine()

void LocalFile::nextLine ( Char * buf = NULL,
Int bufSize = 0 )
virtual

moves file position to after the next new-line

Implements File.

Definition at line 546 of file LocalFile.cpp.

◆ open()

Bool LocalFile::open ( const Char * filename,
Int access = 0 )
virtual

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.

DEBUG_LOG(("LocalFile::open %s (total %d)\n",filename,s_totalOpen));

Reimplemented from File.

Definition at line 166 of file LocalFile.cpp.

◆ read()

Int LocalFile::read ( void * buffer,
Int bytes )
virtual

Read the specified number of bytes in to buffer: See File::read.

Reimplemented from File.

Definition at line 316 of file LocalFile.cpp.

◆ readEntireAndClose()

char * LocalFile::readEntireAndClose ( )
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.

Definition at line 617 of file LocalFile.cpp.

◆ scanInt()

Bool LocalFile::scanInt ( Int & newInt)
virtual

return what gets read in as an integer at the current file position.

Implements File.

Definition at line 405 of file LocalFile.cpp.

◆ scanReal()

Bool LocalFile::scanReal ( Real & newReal)
virtual

return what gets read in as a float at the current file position.

Implements File.

Definition at line 452 of file LocalFile.cpp.

◆ scanString()

Bool LocalFile::scanString ( AsciiString & newString)
virtual

return what gets read in as a string at the current file position.

Implements File.

Definition at line 502 of file LocalFile.cpp.

◆ seek()

Int LocalFile::seek ( Int new_pos,
seekMode mode = CURRENT )
virtual

Set file position: See File::seek.

Reimplemented from File.

Definition at line 367 of file LocalFile.cpp.

◆ write()

Int LocalFile::write ( const void * buffer,
Int bytes )
virtual

Write the specified number of bytes from the buffer: See File::write.

Reimplemented from File.

Definition at line 347 of file LocalFile.cpp.


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