Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::IO::FileReader Class Reference

#include <FileReader.h>

Public Types

using SizeType = AZ::u64
 

Public Member Functions

 FileReader ()
 Creates FileReader instance in the default state with no file opened.
 
 FileReader (AZ::IO::FileIOBase *fileIoBase, const char *filePath)
 
 FileReader (FileReader &&other)
 Takes ownership of the supplied FileReader handle.
 
FileReaderoperator= (FileReader &&other)
 Moves ownership of FileReader handle to this instance.
 
bool Open (AZ::IO::FileIOBase *fileIoBase, const char *filePath)
 
bool IsOpen () const
 
void Close ()
 Closes the File.
 
SizeType Length () const
 Retrieve the length of the OpenFile.
 
SizeType Read (SizeType byteSize, void *buffer)
 
SizeType Tell () const
 
bool Seek (AZ::s64 offset, SeekType type)
 
bool Eof () const
 Returns true if the file is open and in the EOF state.
 
bool GetFilePath (AZ::IO::FixedMaxPath &filePath) const
 

Static Public Member Functions

static FileReader GetStdin ()
 

Detailed Description

Structure which encapsulates delegates File Read operations to either the FileIOBase or SystemFile classes based if a FileIOBase* instance has been supplied to the FileSystemReader class the SettingsRegistry option to use FileIO

Constructor & Destructor Documentation

◆ FileReader()

AZ::IO::FileReader::FileReader ( AZ::IO::FileIOBase fileIoBase,
const char *  filePath 
)

Creates a new FileReader instance and attempts to open the file at the supplied path Uses the FileIOBase instance if supplied

Parameters
fileIOBasepointer to fileIOBase instance
null-terminatedfilePath to open

Member Function Documentation

◆ GetFilePath()

bool AZ::IO::FileReader::GetFilePath ( AZ::IO::FixedMaxPath filePath) const

Store the file path of the open file into the output file path parameter The filePath reference is left unmodified, if the path was not stored

Returns
true if the filePath was stored

◆ GetStdin()

static FileReader AZ::IO::FileReader::GetStdin ( )
static

Returns a FileReader which wraps the SystemFile handle to stdin descriptor

◆ IsOpen()

bool AZ::IO::FileReader::IsOpen ( ) const

Returns true if a file is currently open

Returns
true if the file is open

◆ Open()

bool AZ::IO::FileReader::Open ( AZ::IO::FileIOBase fileIoBase,
const char *  filePath 
)

Opens a File using the FileIOBase instance if non-nullptr Otherwise fall back to use SystemFile

Parameters
fileIOBasepointer to fileIOBase instance
null-terminatedfilePath to open
Returns
true if the File is opened successfully

◆ Read()

SizeType AZ::IO::FileReader::Read ( SizeType  byteSize,
void *  buffer 
)

Attempts to read up to byte size bytes into the supplied buffer

Parameters
byteSize- Maximum number of bytes to read
buffer- Buffer to read bytes into
Returns
the number of bytes read if the file is open, otherwise 0

◆ Seek()

bool AZ::IO::FileReader::Seek ( AZ::s64  offset,
SeekType  type 
)

Seeks within the open file to the offset supplied

Parameters
offsetFile offset to seek to
typeparameter to indicate the reference point to start the seek from
Returns
true if the file is open and the seek succeeded

◆ Tell()

SizeType AZ::IO::FileReader::Tell ( ) const

Returns the current file offset

Returns
file offset if the file is open, otherwise 0

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