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::Android::APKFileHandler Class Reference

Public Types

typedef AZStd::function< bool(const char *)> FindDirsCallbackType
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (APKFileHandler, AZ::OSAllocator)
 

Static Public Member Functions

static bool Create ()
 The preferred entry point for the construction of the global APKFileHandler instance.
 
static void Destroy ()
 Public accessor to destroy the APKFileHandler global instance.
 
static FILE * Open (const char *filename, const char *mode, AZ::u64 &size)
 
static int Read (void *asset, char *buffer, int size)
 
static int Write (void *asset, const char *buffer, int size)
 
static fpos_t Seek (void *asset, fpos_t offset, int origin)
 Same as, and is mapped to fseek when a file is opened.
 
static int Close (void *asset)
 
static int FileLength (const char *filename)
 
static AZ::IO::Result ParseDirectory (const char *path, FindDirsCallbackType findCallback)
 
static bool IsDirectory (const char *path)
 Check to see if a given path is a directory or not.
 
static bool DirectoryOrFileExists (const char *path)
 Checks to see if a path (file or directory) exists.
 
static void SetNumBytesToRead (const size_t numBytesToRead)
 Set the correct number of bytes to be read when calls to fread are redirected to APKFileHandler::Read.
 
static void SetLoadFilesToMemory (const char *fileNames)
 Set the names of the files that should be loaded to memory.
 

Member Function Documentation

◆ Close()

static int AZ::Android::APKFileHandler::Close ( void *  asset)
static

Closes the file handle and frees it's allocated resources. Is mapped to fclose when a file is opened.

Returns
0

◆ FileLength()

static int AZ::Android::APKFileHandler::FileLength ( const char *  filename)
static

Get the size, in bytes, of a file

Parameters
filenameThe full path to the file
Returns
The size of the file, in bytes. Returns

◆ Open()

static FILE * AZ::Android::APKFileHandler::Open ( const char *  filename,
const char *  mode,
AZ::u64 &  size 
)
static

Opens a file using the native assets manager and maps standard c file i/o

Parameters
filenameThe full path to the file
modeAccess mode of the file to be opened, will ignore write operations
size[out]Returns the size of the file in bytes
Returns
A standard c file handle

◆ ParseDirectory()

static AZ::IO::Result AZ::Android::APKFileHandler::ParseDirectory ( const char *  path,
FindDirsCallbackType  findCallback 
)
static

Uses JNI to cache the contents of a given directory at path while providing each entry to findCallback

Parameters
pathThe full path to the desired directory
findCallbackCallback used to find a specific file within a given directory
Returns
If the directory was already cached AZ::IO::ResultCode::Success if the directory was already cached or

◆ Read()

static int AZ::Android::APKFileHandler::Read ( void *  asset,
char *  buffer,
int  size 
)
static

Reads size bytes of a given open file. Is mapped to fread when a file is opened

Parameters
assetRaw pointer to the AAsset
bufferData blob to read into
sizeNumber of bytes to read. When called from fread redirect, value could be ignored in favor of using the internal cached version to ensure we are reading only the necessary number of bytes, otherwise we would be reading more than necessary as the redirected seems to only pass in 1024.
Returns
The number of bytes read, zero on EOF, or < 0 on error.

◆ Write()

static int AZ::Android::APKFileHandler::Write ( void *  asset,
const char *  buffer,
int  size 
)
static

Writing to files inside an APK is unsupported. Is mapped to fwrite when a file is opened in order to correctly return an access error.

Returns
EACCES

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