Kanzi  3.9.4
Android application framework API
KanziResourceFile Class Reference

This singleton class handles file access to APK assets. More...

Classes

class  ResourceFile
 Resource File. More...
 

Public Member Functions

void APKCloseFile (ResourceFile file)
 Closes the input stream in given ResourceFile and releases associated resources. More...
 
long APKGetFileLength (ResourceFile file)
 Returns the total number of bytes of ResourceFile's data. More...
 
ResourceFile APKOpenFile (String filename)
 Creates a ResourceFile object containing an open InputStream for the given filename in context set by setContext(Context). More...
 
long APKReadFile (ResourceFile file, int size)
 Reads the specified number of bytes from a given ResourceFile. More...
 
long APKSkipFile (ResourceFile file, int offset)
 Skips over and discards a number bytes of data from ResourceFile's input stream. More...
 
Context getContext ()
 Returns the context which have been set using setContext(Context). More...
 
void setContext (Context context)
 Sets the context of KanziResourceFile. More...
 

Static Public Member Functions

static KanziResourceFile getInstance ()
 Returns an instance of KanziResourceFile. More...
 

Detailed Description

This singleton class handles file access to APK assets.

Member Function Documentation

◆ APKCloseFile()

void APKCloseFile ( ResourceFile  file)

Closes the input stream in given ResourceFile and releases associated resources.

Parameters
fileResourceFile to close.

◆ APKGetFileLength()

long APKGetFileLength ( ResourceFile  file)

Returns the total number of bytes of ResourceFile's data.

May be AssetFileDescriptor#UNKNOWN_LENGTH if the asset extends to the end of the file.

Parameters
fileResourceFile to query.
Returns
File length in bytes. KZS_RESOURCE_FILE_ERROR for unopened. UNKNOWN_LENGTH is possible.

◆ APKOpenFile()

ResourceFile APKOpenFile ( String  filename)

Creates a ResourceFile object containing an open InputStream for the given filename in context set by setContext(Context).

Parameters
filenameA resource file in APK to be opened.
Returns
ResourceFile for reading. Null when request failed and reading is not possible.

◆ APKReadFile()

long APKReadFile ( ResourceFile  file,
int  size 
)

Reads the specified number of bytes from a given ResourceFile.

Reallocates the byte buffer in ResourceFile to

size

bytes, if requested size is larger than the previously allocated size of ResourceFile.

Parameters
fileResourceFile with open InputStream to read.
sizeRead buffer size in bytes.
Returns
Number of bytes read. KZS_RESOURCE_FILE_ERROR on error. KZS_RESOURCE_FILE_EOF when end of file reached.

◆ APKSkipFile()

long APKSkipFile ( ResourceFile  file,
int  offset 
)

Skips over and discards a number bytes of data from ResourceFile's input stream.

The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned. If offset is negative, this method returns 0, and no bytes are skipped.

Parameters
fileResourceFile to read.
offsetNumber of bytes to skip.
Returns
The actual number of bytes skipped.

◆ getContext()

Context getContext ( )

Returns the context which have been set using setContext(Context).

Returns
context

◆ getInstance()

static KanziResourceFile getInstance ( )
static

Returns an instance of KanziResourceFile.

Before using the returned instance for the first time, context has to be set once using setContext(Context). Context defaults to null and APKOpenFile(String) requests will fail until set.

Returns
Singleton instance.

◆ setContext()

void setContext ( Context  context)

Sets the context of KanziResourceFile.

Parameters
contextThe application's context utilizing KanziResourceFile's services.