My Project
|
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... | |
ParaIO class: IO functions ported to the scripting system.
|
static |
add a new variable to the replaceable pool
sVarName | the variable name without enclosing %%, such as "WORLD", "USERID", usually uppercase. |
sVarValue | the path that the variable expands to. If nil, it will remove the variable. |
|
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?
|
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.
|
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.
|
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.
filename | file name to back up |
|
static |
change the file extension.
sFile | the file whose extension to change. |
sExt | the file extension to change to. such as "dds","x" |
|
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.
|
static |
check to see whether an asset file is already downloaded to local disk.
generally return value is larger than 1 if succeed.
|
static |
The CopyFile function copies an existing file to a new file.
src | specifies the name of an existing file |
dest | specifies 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. |
|
static |
Get the CRC 32 code of a given file.
|
static |
make directory
filename | director path. file portion will be automatically striped off. So it is ok to pass in file name, instead of directory name. |
|
static |
deprecated: use ParaIO.open create a new file for writing.
it will make all necessary directories in order to create the file.
|
static |
replace variables in input path and return the result path.
see AddPathVariable
input | a path with or without replaceable. make sure you have called ToCanonicalFilePath() to canonicalize the input before calling this function |
|
static |
delete a given file.
It will reject any system files outside the application directory. after all, this function is of high security level.
sFilePattern | such as "*.dds", "temp.txt", etc |
|
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.
|
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.
|
static |
Check whether a given file exists on disk.
filename | file name to check |
bSearchZipFiles | if 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. |
|
static |
see DoesFileExist().
This version is same as DoesFileExist(filename, false);
|
static |
this does reverse of DecodePath.
see AddPathVariable
input | a path with or without replaceable. make sure you have called ToCanonicalFilePath() to canonicalize the input before calling this function |
|
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.
varNames | a comma separated list of variable names. like "WORLD,USERID", etc. |
|
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
sRelativePath | the absolute path from which to obtain the relative path. It should not begin with "/" |
sRootPath | the parent root path, which will be removed from the absolute path. It should end with "/" |
|
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.
|
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/"
dwDirectoryType | it 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, }; |
|
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.
|
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.
|
static |
get the file extension.
this function may return "" if no file extension is found
|
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.
|
static |
get file info
inout | {modification, attr, access, create, size, mode="file|directoy|fileinzip|", fullpath=string} |
|
static |
get only the file name from the file path.
"a.x" = GetFileName("c:/lxzsrc/a.x");
|
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.
|
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
|
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.
|
static |
trim the sFile by nParentCounts number of parent directories.
nParentCounts | number of parent directory to remove |
|
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.
|
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
sAbsolutePath | the absolute path from which to obtain the relative path. |
sRootPath | the parent root path, which will be removed from the absolute path. It should end with "/" |
|
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.
|
static |
The MoveFile function will move (rename) either a file or a directory (including its children) either in the same directory or across directories.
src | specifies the name of an existing file |
dest | specifies the name of the new file |
|
static |
Open or create a file e.g.
ParaIO.open("temp/test.txt", "w");
filename | the file name to open. if it is "<memory>" and mode is "w". it is a memory buffer. |
mode | : access mode
|
|
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()
filename | the asset file key to open. The actual file opened may from the temp/cache/ folder. |
bDownloadIfNotUpToDate | default 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. |
|
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.
|
static |
open an image file.
The r,g,b can then be retrieved as bytes arrays using ReadBytes() function.
filename | such 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
|
|
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.
|
static |
read line from stdin and automatically add to history
prompt | the default prompt like "> ", ">> " or just "" |
|
static |
search files at once.
sRootPath | the root path. for example: "", "xmodel/","xmodel/models/". Other format is not acceptable |
sFilePattern | file 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. |
sZipArchive | it can be "" or a zip archive file name. . if it is not, only that archive files are saved.
|
nSubLevel | how many sub folders of sRootPath to look into. default value is 0, which only searches the sRootPath folder. |
nMaxFilesNum | one 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. |
nFrom | only contains results from nFrom to (nFrom+nMaxFilesNum) |
|
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.
nPriority | 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. |
|
static |
similar to SyncFile(), except that this function will return immediately and does not redownload or call AddDownloadCount.
And use callback.
sCallBackScript | the 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. |
|
static |
convert a file name to canonical file path
sfilename | it is assumed that strlen(filename) <= MAX_PATH |
bBackSlash | if true, the file will use '\'; otherwise use '/'. '\' is win32 compatible. '/' is more user friendly. |
|
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.
|
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);
dirName | such as "_InstallFiles/" |
bOverwrite | if this is true, existing files will be overridden. |