ZFFramework
 
Loading...
Searching...
No Matches
ZFFile_res.h File Reference

file utility More...

#include "ZFFile_fwd.h"

Go to the source code of this file.

Functions

void ZFResExtPathAdd (const ZFPathInfo &pathInfo)
 add an additional path to search as resource files
 
void ZFResExtPathRemove (const ZFPathInfo &pathInfo)
 see ZFResExtPathAdd
 
ZFCoreArray< ZFPathInfoZFResExtPathList ()
 see ZFResExtPathAdd
 
zfbool ZFResExtPathCheck (ZFPathInfo &resExtPath, const zfchar *resPath)
 see ZFResExtPathAdd
 
zfbool ZFResIsExist (const zfchar *resPath)
 return true if res file specified by path is exist
 
zfbool ZFResIsDir (const zfchar *resPath)
 return true if res file specified by path is a directory
 
zfbool ZFResCopy (const zfchar *resPath, const zfchar *dstPath, zfbool isRecursive=(_ZFT_t_zftrue), zfbool isForce=(_ZFT_t_zftrue))
 res version of ZFFileCopy
 
zfbool ZFResFindFirst (ZFFileFindData &fd, const zfchar *resPath)
 
zfbool ZFResFindNext (ZFFileFindData &fd)
 
void ZFResFindClose (ZFFileFindData &fd)
 
void * ZFResOpen (const zfchar *resPath)
 open a resource file for read only, see ZFFileOpen
 
zfbool ZFResClose (void *token)
 see ZFResOpen ZFFileClose
 
zfindex ZFResTell (void *token)
 see ZFResOpen ZFFileTell
 
zfbool ZFResSeek (void *token, zfindex byteSize, ZFSeekPos position=(ZFSeekPosBegin))
 see ZFResOpen ZFFileSeek
 
zfindex ZFResRead (void *token, void *buf, zfindex maxByteSize)
 see ZFResOpen ZFFileRead
 
zfbool ZFResIsEof (void *token)
 see ZFResOpen ZFFileIsEof
 
zfbool ZFResIsError (void *token)
 see ZFResOpen ZFFileIsEof
 
zfindex ZFResSize (void *token)
 see ZFResOpen, ZFFileSize
 

Detailed Description

file utility

Function Documentation

◆ ZFResExtPathAdd()

void ZFResExtPathAdd ( const ZFPathInfo & pathInfo)
extern

add an additional path to search as resource files

by default, resource files are placed in a fixed builtin location, you may add additional path to search as resource files
to make things clear, while accessing resource files using a res path, we would:

  1. search all additional resource path to find whether the file exists
  2. if exist, use the additional resource file
  3. if not exist, use builtin resource file
  4. if builtin resource file not exist, fail

this method would affect all methods that process with resource files, such as ZFResCopy, ZFResOpen, ZFResRead
typically, additional resource path should be modified during startup only

◆ ZFResExtPathCheck()

zfbool ZFResExtPathCheck ( ZFPathInfo & resExtPath,
const zfchar * resPath )
extern

see ZFResExtPathAdd

return the registered additional resource path if file exist, or null if not exist
if return value is not null, the final file path should be "return value + '/' + resPath"

Note
path must be well formed, use ZFPathFormat if necessary

◆ ZFResIsExist()

zfbool ZFResIsExist ( const zfchar * resPath)
extern

return true if res file specified by path is exist

Note
path must be well formed, use ZFPathFormat if necessary

◆ ZFResIsDir()

zfbool ZFResIsDir ( const zfchar * resPath)
extern

return true if res file specified by path is a directory

Note
path must be well formed, use ZFPathFormat if necessary

◆ ZFResCopy()

zfbool ZFResCopy ( const zfchar * resPath,
const zfchar * dstPath,
zfbool isRecursive = (_ZFT_t_zftrue),
zfbool isForce = (_ZFT_t_zftrue) )
extern

res version of ZFFileCopy

Note
path must be well formed, use ZFPathFormat if necessary

◆ ZFResFindFirst()

zfbool ZFResFindFirst ( ZFFileFindData & fd,
const zfchar * resPath )
extern
See also
see ZFResOpen, ZFFileFindFirst

use empty string to find resource's root directory

Note
path must be well formed, use ZFPathFormat if necessary

◆ ZFResFindNext()

zfbool ZFResFindNext ( ZFFileFindData & fd)
extern
See also
see ZFResOpen, ZFFileFindNext

◆ ZFResFindClose()

void ZFResFindClose ( ZFFileFindData & fd)
extern
See also
see ZFResOpen, ZFFileFindClose

◆ ZFResOpen()

void * ZFResOpen ( const zfchar * resPath)
extern

open a resource file for read only, see ZFFileOpen

since the resource files may or may not be opened by normal method (i.e. ZFFileOpen), such as those in Android project which are located in apk/assets, so use ZFResOpen and ZFResFindFirst to access it for cross-platform
also, since the resource files may or may not be compressed into app, accessing them may or may not take much time
a resource file is a file in "zfres" directory of native project, such as "project_path/zfres/1.png" and "project_path/zfres/subdir/1.png", which should be "1.png" and "subdir/1.png" when ZFResOpen
file name could be the same if under different directories, and is recommended to keep all lower case for cross-platform

note that the token is defined same type as the one used by ZFFileOpen, it's your responsibility to make sure not to misuse it

Note
path must be well formed, use ZFPathFormat if necessary

ADVANCED:
resource can be "extended" by ZFResExtPathAdd, use ZFResRaw series to bypass the logic