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

#include <WSYS_StdFile.h>

Inherits File.

Public Member Functions

 StdFile ()
 
virtual ~StdFile ()
 
virtual Bool open (const Char *filename, Int access=0)
 Open a fioe 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.
 
- Public Member Functions inherited from File
Bool eof ()
 
virtual Int write (const void *buffer, Int bytes)
 
virtual void nextLine (Char *buf=NULL, Int bufSize=0)=0
 reads until it reaches a new-line character
 
virtual Bool scanInt (Int &newInt)=0
 read an integer from the current file position.
 
virtual Bool scanReal (Real &newReal)=0
 read a real number from the current file position.
 
virtual Bool scanString (AsciiString &newString)=0
 read a string from the current file position.
 
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 char * readEntireAndClose ()=0
 
virtual FileconvertToRAMFile ()=0
 
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 ()
 

Protected Attributes

int m_handle
 Std C file handle.
 
- 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 MemoryPoolgetObjectMemoryPool ()=0
 

Detailed Description

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

Definition at line 69 of file WSYS_StdFile.h.

Constructor & Destructor Documentation

◆ StdFile()

StdFile::StdFile ( )

Definition at line 95 of file WSYS_StdFile.cpp.

◆ ~StdFile()

StdFile::~StdFile ( )
virtual

Definition at line 111 of file WSYS_StdFile.cpp.

Member Function Documentation

◆ close()

void StdFile::close ( void )
virtual

Close the file.

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

Reimplemented from File.

Definition at line 194 of file WSYS_StdFile.cpp.

◆ open()

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

Open a fioe 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.

Definition at line 133 of file WSYS_StdFile.cpp.

◆ read()

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

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

Reimplemented from File.

Definition at line 203 of file WSYS_StdFile.cpp.

◆ seek()

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

Set file position: See File::seek.

Reimplemented from File.

Definition at line 233 of file WSYS_StdFile.cpp.

◆ write()

Int StdFile::write ( void * buffer,
Int bytes )
virtual

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

Reimplemented from File.

Definition at line 217 of file WSYS_StdFile.cpp.

Member Data Documentation

◆ m_handle

int StdFile::m_handle
protected

Std C file handle.

Definition at line 73 of file WSYS_StdFile.h.


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