Open 3D Engine EMotionFX Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
MCore::File Class Referenceabstract

#include <File.h>

Inherits MCore::Stream.

Inherited by MCore::DiskFile, and MCore::MemoryFile.

Public Member Functions

 File ()
 
virtual ~File ()
 
virtual void Close ()=0
 
virtual void Flush ()=0
 
virtual bool GetIsEOF () const =0
 
virtual uint8 GetNextByte ()=0
 
virtual size_t GetPos () const =0
 
virtual size_t GetFileSize () const =0
 
virtual bool WriteByte (uint8 value)=0
 
virtual bool Forward (size_t numBytes)=0
 
virtual bool Seek (size_t offset)=0
 
virtual size_t Read (void *data, size_t length)=0
 
virtual size_t Write (const void *data, size_t length)=0
 
virtual bool GetIsOpen () const =0
 
- Public Member Functions inherited from MCore::Stream
 Stream ()
 
virtual ~Stream ()
 
virtual uint32 GetType () const =0
 
virtual Streamoperator<< (bool b)
 
virtual Streamoperator<< (char ch)
 
virtual Streamoperator<< (uint8 ch)
 
virtual Streamoperator<< (int16 number)
 
virtual Streamoperator<< (uint16 number)
 
virtual Streamoperator<< (int32 number)
 
virtual Streamoperator<< (uint32 number)
 
virtual Streamoperator<< (uint64 number)
 
virtual Streamoperator<< (int64 number)
 
virtual Streamoperator<< (float number)
 
virtual Streamoperator<< (double number)
 
virtual Streamoperator<< (AZStd::string &text)
 
virtual Streamoperator<< (const char *text)
 
virtual Streamoperator>> (bool &b)
 
virtual Streamoperator>> (char &ch)
 
virtual Streamoperator>> (uint8 &ch)
 
virtual Streamoperator>> (int16 &number)
 
virtual Streamoperator>> (uint16 &number)
 
virtual Streamoperator>> (int32 &number)
 
virtual Streamoperator>> (uint32 &number)
 
virtual Streamoperator>> (int64 &number)
 
virtual Streamoperator>> (uint64 &number)
 
virtual Streamoperator>> (float &number)
 
virtual Streamoperator>> (double &number)
 
virtual Streamoperator>> (AZStd::string &text)
 

Detailed Description

The file abstract base class. This class represents some file from which the user can read, write, etc. Do not just think of this as only a file on disk. A file could be virtually anything from which can be read and to which can be written. Like a stream, but with more functionalities. For example the file could also be a specified section in your systems main memory. Another example could be the file being some sort of network stream.

Constructor & Destructor Documentation

◆ File()

MCore::File::File ( )
inline

The constructor.

◆ ~File()

virtual MCore::File::~File ( )
inlinevirtual

The destructor.

Member Function Documentation

◆ Close()

virtual void MCore::File::Close ( )
pure virtual

Close the file.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ Flush()

virtual void MCore::File::Flush ( )
pure virtual

Flush the file. All cached (not yet written) data will be forced to written when calling this method.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ Forward()

virtual bool MCore::File::Forward ( size_t  numBytes)
pure virtual

Seek ahead a given number of bytes. This can be used to skip a given number of upcoming bytes in the file.

Parameters
numBytesThe number of bytes to seek ahead.
Returns
Returns true when succeeded or false when an error occured (for example when we where trying to read past the end of the file).

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ GetFileSize()

virtual size_t MCore::File::GetFileSize ( ) const
pure virtual

Returns the size of this file in bytes.

Returns
The filesize in bytes.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ GetIsEOF()

virtual bool MCore::File::GetIsEOF ( ) const
pure virtual

Check if we reached the end of the file or not.

Returns
Returns true when we have returned the end of the file. Otherwise false is returned.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ GetIsOpen()

virtual bool MCore::File::GetIsOpen ( ) const
pure virtual

Check if the file has been opened already.

Returns
Returns true when the file has been opened, otherwise false.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ GetNextByte()

virtual uint8 MCore::File::GetNextByte ( )
pure virtual

Reads and returns the next byte/character in the file. So this will increase the position in the file with one.

Returns
The character or byte read.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ GetPos()

virtual size_t MCore::File::GetPos ( ) const
pure virtual

Returns the position in the file.

Returns
The offset in the file in bytes.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ Read()

virtual size_t MCore::File::Read ( void *  data,
size_t  length 
)
pure virtual

Read a given amount of data from the file.

Parameters
dataThe pointer where to store the read data.
lengthThe size in bytes of the data to read.
Returns
Returns the number of read bytes.

Reimplemented from MCore::Stream.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ Seek()

virtual bool MCore::File::Seek ( size_t  offset)
pure virtual

Seek to a given byte position in the file, where 0 would be the beginning of the file. So we're talking about the absolute position in the file. After successfully executing this method the method GetPos will return the given offset.

Parameters
offsetThe offset in bytes (the position) in the file to seek to.
Returns
Returns true when successfully moved to the given position in the file, otherwise false.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ Write()

virtual size_t MCore::File::Write ( const void *  data,
size_t  length 
)
pure virtual

Writes a given amount of data to the file.

Parameters
dataThe pointer to the data to write.
lengthThe size in bytes of the data to write.
Returns
Returns the number of written bytes.

Reimplemented from MCore::Stream.

Implemented in MCore::MemoryFile, and MCore::DiskFile.

◆ WriteByte()

virtual bool MCore::File::WriteByte ( uint8  value)
pure virtual

Write a character or byte in the file.

Parameters
valueThe character or byte to write.
Returns
Returns true when successfully written, otherwise false is returned.

Implemented in MCore::MemoryFile, and MCore::DiskFile.


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