My Project
Static Public Member Functions | List of all members
ParaScripting::ParaIO Class Reference

ParaIO class: IO functions ported to the scripting system. More...

#include <ParaScriptingIO.h>

Static Public Member Functions

static const char * DecodePath (const char *input)
 replace variables in input path and return the result path. More...
 
static const char * EncodePath (const char *input)
 this does reverse of DecodePath. More...
 
static const char * EncodePath2 (const char *input, const char *varNames)
 same as EncodePath, except that it will only replace variables who name appears in varNames. More...
 
static bool AddPathVariable (const char *sVarName, const char *sVarValue)
 add a new variable to the replaceable pool More...
 
static bool AddSearchPath (const char *sFile)
 add a search path to the search path pool. More...
 
static bool AddSearchPath2 (const char *sFile, int nPriority)
 
static bool RemoveSearchPath (const char *sFile)
 remove a search path from the search path pool.
 
static const std::string & GetWritablePath ()
 get writable path
 
static bool ClearAllSearchPath ()
 clear all search paths.
 
static unsigned long CRC32 (const char *filename)
 Get the CRC 32 code of a given file. More...
 
static void UpdateMirrorFiles (const char *dirName, bool bOverwrite)
 this function is equivalent to calling the following functions. More...
 
static ParaZipWriter CreateZip (const char *fn, const char *password)
 call this to start the creation of a zip file.
 
static int DeleteFile (const char *sFilePattern)
 delete a given file. More...
 
static bool MoveFile (const char *src, const char *dest)
 The MoveFile function will move (rename) either a file or a directory (including its children) either in the same directory or across directories. More...
 
static bool CopyFile (const char *src, const char *dest, bool bOverride)
 The CopyFile function copies an existing file to a new file. More...
 
static ParaFileObject OpenAssetFile (const char *filename)
 This is rather similar to OpenFile() method, except that it will first look in the AssetManifest to see if the file exit. More...
 
static ParaFileObject OpenAssetFile2 (const char *filename, bool bDownloadIfNotUpToDate)
 
static bool DoesAssetFileExist (const char *filename)
 check to see whether we have a up to date version of an asset file. More...
 
static bool DoesAssetFileExist2 (const char *filename, bool bSearchZipFile)
 same as DoesAssetFileExist, except that if bSearchZipFile == false, it is equivalent to DoesFileExist().
 
static int SyncAssetFile_Async (const char *filename, const char *sCallBackScript)
 similar to SyncFile(), except that this function will return immediately and does not redownload or call AddDownloadCount. More...
 
static int CheckAssetFile (const char *filename)
 check to see whether an asset file is already downloaded to local disk. More...
 
static void LoadReplaceFile (const char *filename, bool bReplaceExistingOnes)
 
static ParaFileObject open (const char *filename, const char *mode)
 Open or create a file e.g. More...
 
static ParaFileObject openimage (const char *filename, const char *mode)
 open an image file. More...
 
static ParaFileObject openimage2 (const char *filename, const char *mode, const object &oExInfo)
 
static bool CreateDirectory (const char *filename)
 make directory More...
 
static bool CreateNewFile (const char *filename)
 deprecated: use ParaIO.open create a new file for writing. More...
 
static bool OpenFileWrite (const char *filename)
 deprecated: use ParaIO.open open a new file for write-only access. More...
 
static bool OpenFile (const char *filename)
 deprecated: use ParaIO.open Open a file for read-only access.
 
static void CloseFile ()
 deprecated: use ParaIO.open Close the current file.
 
static void WriteString (const char *str)
 deprecated: use ParaIO.open write a string to the current file.
 
static void write (const char *buffer, int nSize)
 deprecated: use ParaIO.open write a buffer to the current file.
 
static const char * readline ()
 if no file is opened, it means readline from stdin. More...
 
static const char * readline2 (const char *prompt)
 read line from stdin and automatically add to history More...
 
static bool DoesFileExist (const char *filename, bool bSearchZipFiles)
 Check whether a given file exists on disk. More...
 
static bool DoesFileExist_ (const char *filename)
 see DoesFileExist(). More...
 
static bool BackupFile (const char *filename)
 backup a specified file, if the file exists. More...
 
static ParaSearchResult SearchFiles (const char *sRootPath, const char *sFilePattern, const char *sZipArchive, int nSubLevel, int nMaxFilesNum, int nFrom)
 search files at once. More...
 
static ParaSearchResult SearchFiles_c (const char *sRootPath, const char *sFilePattern, const char *sZipArchive, int nSubLevel)
 
static string GetCurDirectory (DWORD dwDirectoryType)
 get the current directory of the application. More...
 
static const char * GetCurDirectory_ (DWORD dwDirectoryType)
 this should never be called from the scripting interface. More...
 
static string GetParentDirectoryFromPath (const char *sfilename, int nParentCounts)
 trim the sFile by nParentCounts number of parent directories. More...
 
static const char * GetParentDirectoryFromPath_ (const char *sfilename, int nParentCounts)
 this should never be called from the scripting interface. More...
 
static string AutoFindParaEngineRootPath (const char *sFile)
 This will find the root path from a given directory path using the following rule: find a file called "ParaEngine.sig" in the parent directories of sFile, from near to far. More...
 
static const char * AutoFindParaEngineRootPath_ (const char *sFile)
 this should never be called from the scripting interface. More...
 
static string ChangeFileExtension (const char *sFile, const string &sExt)
 change the file extension. More...
 
static const char * ChangeFileExtension_ (const char *sFile, const string &sExt)
 this should never be called from the scripting interface. More...
 
static string GetFileExtension (const char *sFile)
 get the file extension. More...
 
static const char * GetFileExtension_ (const char *sFile)
 this should never be called from the scripting interface. More...
 
static string GetRelativePath (const char *sAbsolutePath, const char *sRootPath)
 Get the relative file path by stripping the root path from the beginning. More...
 
static const char * GetRelativePath_ (const char *sAbsolutePath, const char *sRootPath)
 this should never be called from the scripting interface. More...
 
static string GetAbsolutePath (const char *sRelativePath, const char *sRootPath)
 Get the absolute file path by appending the root path before the relative path. More...
 
static const char * GetAbsolutePath_ (const char *sRelativePath, const char *sRootPath)
 this should never be called from the scripting interface. More...
 
static string GetFileName (const char *sFilePath)
 get only the file name from the file path. More...
 
static const char * GetFileName_ (const char *sFilePath)
 this should never be called from the scripting interface. More...
 
static int GetFileSize (const char *sFilePath)
 The GetFileSize function retrieves the size of the specified file. More...
 
static bool GetFileInfo (const char *sFilePath, const object &inout)
 get file info More...
 
static string ToCanonicalFilePath (const char *sfilename, bool bBackSlash)
 convert a file name to canonical file path More...
 
static const char * ToCanonicalFilePath__ (const char *sfilename, bool bBackSlash)
 this should never be called from the scripting interface. More...
 
static void SetDiskFilePriority (int nPriority)
 set the disk file priority. More...
 
static int GetDiskFilePriority ()
 set the disk file priority. More...
 
static ParaFileSystemWatcher GetFileSystemWatcher (const char *filename)
 create and get a file system watcher object. More...
 
static void DeleteFileSystemWatcher (const char *name)
 delete a watcher, it will no longer receive callbacks. More...
 

Detailed Description

ParaIO class: IO functions ported to the scripting system.

Member Function Documentation

§ AddPathVariable()

bool ParaScripting::ParaIO::AddPathVariable ( const char *  sVarName,
const char *  sVarValue 
)
static

add a new variable to the replaceable pool

Parameters
sVarNamethe variable name without enclosing %%, such as "WORLD", "USERID", usually uppercase.
sVarValuethe path that the variable expands to. If nil, it will remove the variable.
Returns
: true if succeed. it may return false, if a protected variable with the same name already exist but it not editable via scripting interface.

§ AddSearchPath()

bool ParaScripting::ParaIO::AddSearchPath ( const char *  sFile)
static

add a search path to the search path pool.

It will internally normalize the path and check for duplicates note: this function shall not be called by an untrusted client, since it will secretly swap files. : shall we support remote http zip file as a valid search path?

§ AutoFindParaEngineRootPath()

string ParaScripting::ParaIO::AutoFindParaEngineRootPath ( const char *  sFile)
static

This will find the root path from a given directory path using the following rule: find a file called "ParaEngine.sig" in the parent directories of sFile, from near to far.

e.g. if sFile is "c:/a/b/c/xxx.x", then it will search for "c:/a/b/c/","c:/a/b/","c:/a/" and "c:/". the function will return the first parent directory that contains the file, otherwise "" is returned.

§ AutoFindParaEngineRootPath_()

const char * ParaScripting::ParaIO::AutoFindParaEngineRootPath_ ( const char *  sFile)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ BackupFile()

bool ParaScripting::ParaIO::BackupFile ( const char *  filename)
static

backup a specified file, if the file exists.

A new file with an extension ".bak" appended to the end of the original file will be created, whose content is identical to the original file.

Parameters
filenamefile name to back up
Returns
: return true if the file is backed up. return false, if the file does not exist or some error occurs during backup.

§ ChangeFileExtension()

string ParaScripting::ParaIO::ChangeFileExtension ( const char *  sFile,
const string &  sExt 
)
static

change the file extension.

Parameters
sFilethe file whose extension to change.
sExtthe file extension to change to. such as "dds","x"
Returns
: return the file with the changed extension. the input file does not contain a valid file extension, the returned string will be identical to the input file.

§ ChangeFileExtension_()

const char * ParaScripting::ParaIO::ChangeFileExtension_ ( const char *  sFile,
const string &  sExt 
)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ CheckAssetFile()

int ParaScripting::ParaIO::CheckAssetFile ( const char *  filename)
static

check to see whether an asset file is already downloaded to local disk.

generally return value is larger than 1 if succeed.

Returns
: 1 if already downloaded; 0 if asset has not been downloaded; -1 if we are unable to download the asset file after trying serveral times; -3 if asset is being downloaded but is not completed; -4 if input file is not an asset file.

§ CopyFile()

bool ParaScripting::ParaIO::CopyFile ( const char *  src,
const char *  dest,
bool  bOverride 
)
static

The CopyFile function copies an existing file to a new file.

Parameters
srcspecifies the name of an existing file
destspecifies the name of the new file
bOverride[in] If this parameter is false and the new file specified by src already exists, the function fails. If this parameter is true and the new file already exists, the function overwrites the existing file and succeeds.
Returns
true if succeeds

§ CRC32()

unsigned long ParaScripting::ParaIO::CRC32 ( const char *  filename)
static

Get the CRC 32 code of a given file.

Returns
: return 0 if not succeed, otherwise the CRC32 code is returned.

§ CreateDirectory()

bool ParaScripting::ParaIO::CreateDirectory ( const char *  filename)
static

make directory

Parameters
filenamedirector path. file portion will be automatically striped off. So it is ok to pass in file name, instead of directory name.
Returns
: true if the directory is made or already exists

§ CreateNewFile()

bool ParaScripting::ParaIO::CreateNewFile ( const char *  filename)
static

deprecated: use ParaIO.open create a new file for writing.

it will make all necessary directories in order to create the file.

§ DecodePath()

const char * ParaScripting::ParaIO::DecodePath ( const char *  input)
static

replace variables in input path and return the result path.

see AddPathVariable

Parameters
inputa path with or without replaceable. make sure you have called ToCanonicalFilePath() to canonicalize the input before calling this function
Returns
the resulting path. Please note that the return value is the input itself if nothing is replaced. otherwise, it is a static string reference containing the result. therefore the result is NOT thread safe.

§ DeleteFile()

int ParaScripting::ParaIO::DeleteFile ( const char *  sFilePattern)
static

delete a given file.

It will reject any system files outside the application directory. after all, this function is of high security level.

Parameters
sFilePatternsuch as "*.dds", "temp.txt", etc
Returns
: the number of files deleted.

§ DeleteFileSystemWatcher()

void ParaScripting::ParaIO::DeleteFileSystemWatcher ( const char *  name)
static

delete a watcher, it will no longer receive callbacks.

note that if someone else still keeps a pointer to the directory watcher, it will not be deleted.

§ DoesAssetFileExist()

bool ParaScripting::ParaIO::DoesAssetFileExist ( const char *  filename)
static

check to see whether we have a up to date version of an asset file.

if the asset file does not appear in asset manifest list, it will return the result of DoesFileExist() instead.

§ DoesFileExist()

bool ParaScripting::ParaIO::DoesFileExist ( const char *  filename,
bool  bSearchZipFiles 
)
static

Check whether a given file exists on disk.

Parameters
filenamefile name to check
bSearchZipFilesif false, not disk file is searched. If true, both the disk file and zip file will be searched. currently bSearchZipFiles can only be false. Because it is not efficient to check existence of ZIPPED files. Use OpenFile() and check for return value instead.

§ DoesFileExist_()

bool ParaScripting::ParaIO::DoesFileExist_ ( const char *  filename)
static

see DoesFileExist().

This version is same as DoesFileExist(filename, false);

§ EncodePath()

const char * ParaScripting::ParaIO::EncodePath ( const char *  input)
static

this does reverse of DecodePath.

see AddPathVariable

Parameters
inputa path with or without replaceable. make sure you have called ToCanonicalFilePath() to canonicalize the input before calling this function

§ EncodePath2()

const char * ParaScripting::ParaIO::EncodePath2 ( const char *  input,
const char *  varNames 
)
static

same as EncodePath, except that it will only replace variables who name appears in varNames.

varNames is a comma separated list of variable names.

Parameters
varNamesa comma separated list of variable names. like "WORLD,USERID", etc.

§ GetAbsolutePath()

string ParaScripting::ParaIO::GetAbsolutePath ( const char *  sRelativePath,
const char *  sRootPath 
)
static

Get the absolute file path by appending the root path before the relative path.

please note that all paths should uses slash "/", instead of backslash "\", in the path name. letter case is ignored

Parameters
sRelativePaththe absolute path from which to obtain the relative path. It should not begin with "/"
sRootPaththe parent root path, which will be removed from the absolute path. It should end with "/"
Returns
: the relative path is returned. If the absolute path does not math the root path, the absolute path is returned unchanged. e.g. "c:/lxzsrc/a/b.x" = GetAbsolutePath("a/b.x", "c:/lxzsrc/");

§ GetAbsolutePath_()

const char * ParaScripting::ParaIO::GetAbsolutePath_ ( const char *  sRelativePath,
const char *  sRootPath 
)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ GetCurDirectory()

string ParaScripting::ParaIO::GetCurDirectory ( DWORD  dwDirectoryType)
static

get the current directory of the application.

it allows querying a number of standard directories. please note that all directory are returned as absolute path with slash "/" between two level of directories. and that it always ends with "\". e.g. "c:/lxzsrc/paraengineSDK/" or "c:/lxzsrc/paraengineSDK/script/"

Parameters
dwDirectoryTypeit can be one of the PARAENGINE_DIRECTORY enumeration type enum PARAENGINE_DIRECTORY{ APP_ROOT_DIR = 0, APP_SCRIPT_DIR = 1, APP_ARCHIVE_DIR = 2, // xmodels APP_MODEL_DIR = 3, APP_SHADER_DIR = 4, APP_DATABASE_DIR = 5, APP_TEMP_DIR = 6, APP_USER_DIR = 7, APP_BACKUP_DIR = 8, APP_SCREENSHOT_DIR = 9, APP_PLUGIN_DIR = 10, APP_CONFIG_DIR = 11, APP_CHARACTER_DIR = 12, APP_SH_DESKTOP_DIR = 13, APP_SH_DESKTOP_FOLDER_DIR = 14, APP_SH_MYDOC_DIR = 15, APP_SH_FAV_DIR = 16, APP_SH_MUSIC_DIR = 17, APP_SH_PICTURE_DIR = 18, APP_SH_VIDEO_DIR = 19, APP_DEV_DIR = 20, APP_EXECUTABLE_DIR = 21, APP_LAST_DIR, };
Returns
: the directory is returned.

§ GetCurDirectory_()

const char * ParaScripting::ParaIO::GetCurDirectory_ ( DWORD  dwDirectoryType)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ GetDiskFilePriority()

int ParaScripting::ParaIO::GetDiskFilePriority ( )
static

set the disk file priority.

it affects whether the disk will be searched first or the one in the archive files. default disk file will be searched first.

Returns
: 0 is the same priority as the disk file. so 0 or above will cause the disk file to be searched before archive files. below 0, such as -1 will cause the archive files go first.

§ GetFileExtension()

string ParaScripting::ParaIO::GetFileExtension ( const char *  sFile)
static

get the file extension.

this function may return "" if no file extension is found

§ GetFileExtension_()

const char * ParaScripting::ParaIO::GetFileExtension_ ( const char *  sFile)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ GetFileInfo()

bool ParaScripting::ParaIO::GetFileInfo ( const char *  sFilePath,
const object inout 
)
static

get file info

Parameters
inout{modification, attr, access, create, size, mode="file|directoy|fileinzip|", fullpath=string}

§ GetFileName()

string ParaScripting::ParaIO::GetFileName ( const char *  sFilePath)
static

get only the file name from the file path.

"a.x" = GetFileName("c:/lxzsrc/a.x");

§ GetFileName_()

const char * ParaScripting::ParaIO::GetFileName_ ( const char *  sFilePath)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ GetFileSize()

int ParaScripting::ParaIO::GetFileSize ( const char *  sFilePath)
static

The GetFileSize function retrieves the size of the specified file.

The file size that can be reported by this function is limited to a DWORD value

Returns
: size of the file. If the file does not exist or the file size is 0, the return value is 0.
Note
: only disk file is searched.files inside zip file are ignored.

§ GetFileSystemWatcher()

ParaScripting::ParaFileSystemWatcher ParaScripting::ParaIO::GetFileSystemWatcher ( const char *  filename)
static

create and get a file system watcher object.

always use local to retrieve the object to ensure that the object is properly released when out of scope.

§ GetParentDirectoryFromPath()

string ParaScripting::ParaIO::GetParentDirectoryFromPath ( const char *  sfilename,
int  nParentCounts 
)
static

trim the sFile by nParentCounts number of parent directories.

Parameters
nParentCountsnumber of parent directory to remove
Returns
: return "" if the input directory does not have that many parent directories. e.g. "C:/abc/" = GetDirectoryFromPath("C:/abc/aaa",0); "C:/" = GetDirectoryFromPath("C:/abc/",1);

§ GetParentDirectoryFromPath_()

const char * ParaScripting::ParaIO::GetParentDirectoryFromPath_ ( const char *  sfilename,
int  nParentCounts 
)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ GetRelativePath()

string ParaScripting::ParaIO::GetRelativePath ( const char *  sAbsolutePath,
const char *  sRootPath 
)
static

Get the relative file path by stripping the root path from the beginning.

please note that all paths should uses slash "/", instead of backslash "\", in the path name.letter case is ignored

Parameters
sAbsolutePaththe absolute path from which to obtain the relative path.
sRootPaththe parent root path, which will be removed from the absolute path. It should end with "/"
Returns
: the relative path is returned. If the absolute path does not math the root path, the absolute path is returned unchanged. the relative path does not begin with "/" e.g. "a/b.x" = GetRelativePath("c:/lxzsrc/a/b.x", "c:/lxzsrc/"); "c:/lxzsrc/a/b.x" = GetRelativePath("c:/lxzsrc/a/b.x", "c:/srclxz/"); // not match

§ GetRelativePath_()

const char * ParaScripting::ParaIO::GetRelativePath_ ( const char *  sAbsolutePath,
const char *  sRootPath 
)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ MoveFile()

bool ParaScripting::ParaIO::MoveFile ( const char *  src,
const char *  dest 
)
static

The MoveFile function will move (rename) either a file or a directory (including its children) either in the same directory or across directories.

Parameters
srcspecifies the name of an existing file
destspecifies the name of the new file
Returns
true if succeeds

§ open()

ParaFileObject ParaScripting::ParaIO::open ( const char *  filename,
const char *  mode 
)
static

Open or create a file e.g.

ParaIO.open("temp/test.txt", "w");

Parameters
filenamethe file name to open. if it is "<memory>" and mode is "w". it is a memory buffer.
mode: access mode
  • "r" Opens for reading. If the file does not exist or cannot be found, the call fails.
  • "w" Opens an empty file for writing. If the given file exists, its contents are destroyed.If not, file will be created.
  • "a" append to the end of an existing file. if file does not exist, a new one is created.
Returns
file object is returned.

§ OpenAssetFile()

ParaFileObject ParaScripting::ParaIO::OpenAssetFile ( const char *  filename)
static

This is rather similar to OpenFile() method, except that it will first look in the AssetManifest to see if the file exit.

If the file does appear in manifest list, we will download the latest version from the current asset server, if not done before. the download process is SYNCHRONOUS. If the file does not appear in AssetManifest list, this function is equivalent to OpenFile()

Parameters
filenamethe asset file key to open. The actual file opened may from the temp/cache/ folder.
bDownloadIfNotUpToDatedefault to true. if true, we will download the latest version from the current asset server. the download process is synchronous. If false, the function will return 0 immediately, when the caller may consider download the file asynchronously, and then open the file again.
Returns
: 1 if succeed. 0, if file is not downloaded successfully.

§ OpenFileWrite()

bool ParaScripting::ParaIO::OpenFileWrite ( const char *  filename)
static

deprecated: use ParaIO.open open a new file for write-only access.

If the file does not exist, it will be created. if the file exists, the file pointer is at the end of file.

§ openimage()

ParaScripting::ParaFileObject ParaScripting::ParaIO::openimage ( const char *  filename,
const char *  mode 
)
static

open an image file.

The r,g,b can then be retrieved as bytes arrays using ReadBytes() function.

Parameters
filenamesuch as BMP, DDS, JPG, etc. It must be a square image. The size of the image can thus be calculated by file size.
mode: access mode
  • "r8g8b8": each pixel is a three bytes of R,G,B
  • "a8r8g8b8": each pixel is a four bytes of A,R,G,B
  • "float32": each pixel is a four bytes of float. [Not supported yet]

§ readline()

const char * ParaScripting::ParaIO::readline ( )
static

if no file is opened, it means readline from stdin.

a deprecated usage is reading from current open file. read line as a string. The string is guaranteed to be ended with '\0'. if end of file is reached, it will return NULL. which is nil in the script. if a line begins with "--", it is automatically recognized as a comment line and will be skipped. a blank line will also be skipped.

§ readline2()

const char * ParaScripting::ParaIO::readline2 ( const char *  prompt)
static

read line from stdin and automatically add to history

Parameters
promptthe default prompt like "> ", ">> " or just ""

§ SearchFiles()

ParaSearchResult ParaScripting::ParaIO::SearchFiles ( const char *  sRootPath,
const char *  sFilePattern,
const char *  sZipArchive,
int  nSubLevel,
int  nMaxFilesNum,
int  nFrom 
)
static

search files at once.

See also
CSearchResult the current version of this function can support only one query at a time. The search result is invalid if called intermitantly
Parameters
sRootPaththe root path. for example: "", "xmodel/","xmodel/models/". Other format is not acceptable
sFilePatternfile pattern, e.g. "*.x" (all files with x extension), "*" (any files), "*."(directories only) if sZipArchive is non-empty, sFilePattern support both regular expression and wild card search. it performs wild cards search by default, where "/\\" matches to directory. "* "matches to anything except "/\\.", and "." matches to "." itself. e.g.. "*.*", "*.", "worlds/ *.abc", "*abc/ *.jpg", etc it sFilePattern begins with ":", things after ":" is treated like a regular expression. It has the same syntax with the perl regular expression and uses full match. e.g.. ":.*\\.jpg", etc.
sZipArchiveit can be "" or a zip archive file name. . if it is not, only that archive files are saved.
  • "": only disk files are searched
  • "*.zip": currently opened zip files are searched
  • "*.*": search disk file followed by all zip files.
nSubLevelhow many sub folders of sRootPath to look into. default value is 0, which only searches the sRootPath folder.
nMaxFilesNumone can limit the total number of files in the search result. Default value is 50. the search will stop at this value even there are more matching files.
nFromonly contains results from nFrom to (nFrom+nMaxFilesNum)
Returns
: one should manually release the search result.

§ SetDiskFilePriority()

void ParaScripting::ParaIO::SetDiskFilePriority ( int  nPriority)
static

set the disk file priority.

it affects whether the disk will be searched first or the one in the archive files. default disk file will be searched first.

Parameters
nPriority0 is the same priority as the disk file. so 0 or above will cause the disk file to be searched before archive files. below 0, such as -1 will cause the archive files go first.

§ SyncAssetFile_Async()

int ParaScripting::ParaIO::SyncAssetFile_Async ( const char *  filename,
const char *  sCallBackScript 
)
static

similar to SyncFile(), except that this function will return immediately and does not redownload or call AddDownloadCount.

And use callback.

Parameters
sCallBackScriptthe callback script code to be executed when the download is complete. it must begin with ";", such as ";log([[download is complete]]);" the global "msg.res" table contains the error code in case an error is met. msg.res == 0 if succeed, otherwise -1.
Returns
: 0 if download has begun, 1 if file is already downloaded, -1 if failed, -2 if input is not an asset file.

§ ToCanonicalFilePath()

string ParaScripting::ParaIO::ToCanonicalFilePath ( const char *  sfilename,
bool  bBackSlash 
)
static

convert a file name to canonical file path

Parameters
sfilenameit is assumed that strlen(filename) <= MAX_PATH
bBackSlashif true, the file will use '\'; otherwise use '/'. '\' is win32 compatible. '/' is more user friendly.
Returns
: the canonical file path name returned.

§ ToCanonicalFilePath__()

const char * ParaScripting::ParaIO::ToCanonicalFilePath__ ( const char *  sfilename,
bool  bBackSlash 
)
static

this should never be called from the scripting interface.

it is only for API exportation. it uses a static string for the output. so it is not thread-safe.

§ UpdateMirrorFiles()

void ParaScripting::ParaIO::UpdateMirrorFiles ( const char *  dirName,
bool  bOverwrite 
)
static

this function is equivalent to calling the following functions.

LoadLogFromFile("InstallFiles.txt"); LoadLogFromFile("temp/filelog.txt"); MirrorFiles(dirName, bOverwrite);

e.g. UpdateMirrorFiles("_InstallFiles/", true);

Parameters
dirNamesuch as "_InstallFiles/"
bOverwriteif this is true, existing files will be overridden.

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