![]() |
TrinityCore
|
#include <FileSystem.h>
Classes | |
| class | Dir |
| class | Entry |
| class | ListSettings |
Public Member Functions | |
| void | setCacheLifetime (float t) |
Static Public Member Functions | |
| static void | init () |
| static void | cleanup () |
| static bool | inZipfile (const std::string &path, std::string &zipfile) |
| static void | clearCache (const std::string &path="") |
| static FILE * | fopen (const char *filename, const char *mode) |
| static void | fclose (FILE *f) |
| static bool | inZipfile (const std::string &path) |
| static void | removeFile (const std::string &path) |
| Delete this file. No effect if path does not exist. More... | |
| static bool | isZipfile (const std::string &path) |
| static float | cacheLifetime () |
| static void | createDirectory (const std::string &path) |
| static std::string | currentDirectory () |
| static void | copyFile (const std::string &srcPath, const std::string &dstPath) |
| static bool | exists (const std::string &f, bool trustCache=true, bool caseSensitive=true) |
| static bool | isDirectory (const std::string &path) |
| static bool | isFile (const std::string &path) |
| static std::string | resolve (const std::string &path, const std::string &cwd=currentDirectory()) |
| static bool | isNewer (const std::string &src, const std::string &dst) |
| static int64 | size (const std::string &path) |
| static void | list (const std::string &spec, Array< std::string > &result, const ListSettings &listSettings=ListSettings()) |
| static void | getFiles (const std::string &spec, Array< std::string > &result, bool includeParentPath=false) |
| static void | getDirectories (const std::string &spec, Array< std::string > &result, bool includeParentPath=false) |
| static void | markFileUsed (const std::string &filename) |
| static const Set< std::string > & | usedFiles () |
Private Types | |
| enum | Type { UNKNOWN, FILE_TYPE, DIR_TYPE } |
Private Member Functions | |
| Dir & | getContents (const std::string &path, bool forceUpdate) |
| FileSystem () | |
| bool | _inZipfile (const std::string &path, std::string &zipfile) |
| void | _clearCache (const std::string &path) |
| bool | _inZipfile (const std::string &path) |
| void | _setCacheLifetime (float t) |
| float | _cacheLifetime () const |
| void | _createDirectory (const std::string &path) |
| bool | _exists (const std::string &f, bool trustCache=true, bool caseSensitive=true) |
| bool | _isDirectory (const std::string &path) |
| bool | _isFile (const std::string &path) |
| void | _copyFile (const std::string &srcPath, const std::string &dstPath) |
| std::string | _resolve (const std::string &path, const std::string &cwd=currentDirectory()) |
| bool | _isNewer (const std::string &src, const std::string &dst) |
| std::string | _currentDirectory () |
| int64 | _size (const std::string &path) |
| void | listHelper (const std::string &shortSpec, const std::string &parentPath, Array< std::string > &result, const ListSettings &settings) |
| void | _list (const std::string &spec, Array< std::string > &result, const ListSettings &listSettings=ListSettings()) |
| bool | _isZipfile (const std::string &path) |
| void | _getFiles (const std::string &spec, Array< std::string > &result, bool includeParentPath=false) |
| void | _getDirectories (const std::string &spec, Array< std::string > &result, bool includeParentPath=false) |
| FILE * | _fopen (const char *filename, const char *mode) |
| void | _removeFile (const std::string &path) |
| Delete this file. No effect if path does not exist. More... | |
Static Private Member Functions | |
| static FileSystem & | instance () |
Private Attributes | |
| Array< std::string > | m_winDrive |
| float | m_cacheLifetime |
| Table< std::string, Dir > | m_cache |
Static Private Attributes | |
| static GMutex | mutex |
OS-independent file system layer that optimizes the performance of queries by caching and prefetching.
This class uses the following definitions:
In G3D, Zipfiles are transparently treated as if they were directories, provided:
All FileSystem routines invoke FilePath::expandEnvironmentVariables if the input contains a '$'.
The extension requirement allows G3D to quickly identify whether a path could enter a zipfile without forcing it to open all parent directories for reading.
|
private |
|
private |
Don't allow public construction.
Here is the caller graph for this function:
|
inlineprivate |
A cache is used to optimize repeated calls. A cache entry is considered valid for this many seconds after it has been checked.
Here is the caller graph for this function:
|
private |
Clears old cache entries so that exists() and list() will reflect recent changes to the file system.
| path | Clear only path and its subdirectories ("" means clear the entire cache) |
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
| srcPath | Must name a file. |
| dstPath | Must not contain a zipfile. |
Flushes the cache.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Creates the directory named, including any subdirectories that do not already exist.
The directory must not be inside a zipfile.
Flushes the cache.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
The current working directory (cwd). Only ends in a slash if this is the root of the file system.
Here is the caller graph for this function:
|
private |
Returns true if a node named f exists.
| f | If f contains wildcards, the function returns true if any file matches those wildcards. Wildcards may only appear in the base or ext, not the path. Environment variables beginning with dollar signs (e.g., in "$G3DDATA/cubemap"), with optional parens ("$(G3DDATA)") are automatically expanded in f. Default share names on Windows (e.g., "\\mycomputer\c$") are correctly distinguished from empty environment variables. |
| trustCache | If true, uses the cache for optimizing repeated calls in the same parent directory. |
| caseSensitive | If true, the match must have exactly the same case for the base and extension. If false, case is ignored. The default on Windows is false and the default on other operating systems is true. |
Here is the call graph for this function:
Here is the caller graph for this function:Same as the C standard library fopen, but updates the file cache to acknowledge the new file on a write operation.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
list() directories
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
list() files
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if some sub-path of path is a zipfile.
If the path itself is a zipfile, returns false.
| zipfile | The part of path that was the zipfile |
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if some sub-path of path is a zipfile.
If the path itself is a zipfile, returns false.
| zipfile | The part of path that was the zipfile |
Here is the call graph for this function:Known bug: does not work inside zipfiles
Here is the call graph for this function:
Here is the caller graph for this function:Known bug: does not work inside zipfiles
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if dst does not exist or src is newer than dst, according to their time stamps.
Known bug: does not work inside zipfiles.
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if path is a file that is a zipfile. Note that G3D requires zipfiles to have some extension, although it is not required to be "zip"
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Appends all nodes matching spec to the result array.
Wildcards can only appear to the right of the last slash in spec.
The names will not contain parent paths unless includePath == true. These may be relative to the current directory unless spec is fully qualified (can be done with resolveFilename).
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Delete this file. No effect if path does not exist.
| path | May contain wildcards. May not be inside a zipfile. |
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Fully qualifies a filename.
The filename may contain wildcards, in which case the wildcards will be preserved in the returned value.
| cwd | The directory to treat as the "current" directory when resolving a relative path. The default value is the actual current directory. (G3D::Any::sourceDirectory is a common alternative) |
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Returns the length of the file in bytes, or -1 if the file could not be opened.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
A cache is used to optimize repeated calls. A cache entry is considered valid for this many seconds after it has been checked.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
inlinestatic |
|
inlinestatic |
| srcPath | Must name a file. |
| dstPath | Must not contain a zipfile. |
Flushes the cache.
Here is the call graph for this function:
|
inlinestatic |
Creates the directory named, including any subdirectories that do not already exist.
The directory must not be inside a zipfile.
Flushes the cache.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
The current working directory (cwd). Only ends in a slash if this is the root of the file system.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Returns true if a node named f exists.
| f | If f contains wildcards, the function returns true if any file matches those wildcards. Wildcards may only appear in the base or ext, not the path. Environment variables beginning with dollar signs (e.g., in "$G3DDATA/cubemap"), with optional parens ("$(G3DDATA)") are automatically expanded in f. Default share names on Windows (e.g., "\\mycomputer\c$") are correctly distinguished from empty environment variables. |
| trustCache | If true, uses the cache for optimizing repeated calls in the same parent directory. |
| caseSensitive | If true, the match must have exactly the same case for the base and extension. If false, case is ignored. The default on Windows is false and the default on other operating systems is true. |
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Here is the call graph for this function:
Here is the caller graph for this function:Same as the C standard library fopen, but updates the file cache to acknowledge the new file on a write operation.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Update the cache entry for path if it is not already present.
| forceUpdate | If true, always override the current cache value. |
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
list() directories
Here is the call graph for this function:
|
inlinestatic |
list() files
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Create the common instance.
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Returns true if some sub-path of path is a zipfile.
If the path itself is a zipfile, returns false.
| zipfile | The part of path that was the zipfile |
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if some sub-path of path is a zipfile.
If the path itself is a zipfile, returns false.
Here is the call graph for this function:Known bug: does not work inside zipfiles
Here is the call graph for this function:
Here is the caller graph for this function:Known bug: does not work inside zipfiles
Here is the call graph for this function:
|
inlinestatic |
Returns true if dst does not exist or src is newer than dst, according to their time stamps.
Known bug: does not work inside zipfiles.
Here is the call graph for this function:Returns true if path is a file that is a zipfile. Note that G3D requires zipfiles to have some extension, although it is not required to be "zip"
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Appends all nodes matching spec to the result array.
Wildcards can only appear to the right of the last slash in spec.
The names will not contain parent paths unless includePath == true. These may be relative to the current directory unless spec is fully qualified (can be done with resolveFilename).
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Called from list()
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Adds filename to usedFiles(). This is called automatically by open() and all G3D routines that open files.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Delete this file. No effect if path does not exist.
| path | May contain wildcards. May not be inside a zipfile. |
Here is the call graph for this function:
|
inlinestatic |
Fully qualifies a filename.
The filename may contain wildcards, in which case the wildcards will be preserved in the returned value.
| cwd | The directory to treat as the "current" directory when resolving a relative path. The default value is the actual current directory. (G3D::Any::sourceDirectory is a common alternative) |
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Returns the length of the file in bytes, or -1 if the file could not be opened.
Here is the call graph for this function:
Here is the caller graph for this function:All files that have been marked by markFileUsed(). GApp automatically prints this list to log.txt. It is useful for finding the dependencies of your program automatically.
Maps path names (without trailing slashes, except for the file system root) to contents. On Windows, all paths are lowercase
|
private |
|
private |
Drive letters. Only used on windows, but defined on all platforms to help avoid breaking the Windows build when compiling on another platform.
|
staticprivate |
1.8.8