Support Forum G3D Web Page |
OS-independent file system layer that optimizes the performance of queries by caching and prefetching.
More...
Classes | |
class | ListSettings |
Public Member Functions | |
void | setCacheLifetime (float t) |
Set the cacheLifetime(). More... | |
Static Public Member Functions | |
static float | cacheLifetime () |
A cache is used to optimize repeated calls. More... | |
static void | cleanup () |
Destroy the common instance. More... | |
static void | clearCache (const String &path="") |
Clears old cache entries so that exists() and list() will reflect recent changes to the file system. More... | |
static void | clearUsedFiles () |
Clears list of used files marked by markFileUsed(). More... | |
static void | copyDir (const String &srcPath, const String &dstPath) |
More... | |
static void | copyFile (const String &srcPath, const String &dstPath) |
More... | |
static void | createDirectory (const String &path) |
Creates the directory named, including any subdirectories that do not already exist. More... | |
static String | currentDirectory () |
The current working directory (cwd). More... | |
static const Array< String > & | drives () |
On Windows, the drive letters that form the file system roots. More... | |
static bool | exists (const String &f, bool trustCache=true, bool caseSensitive=false) |
Returns true if a node named f exists. More... | |
static void | fclose (FILE *f) |
static FILE * | fopen (const char *filename, const char *mode) |
Same as the C standard library fopen, but updates the file cache to acknowledge the new file on a write operation. More... | |
static void | getDirectories (const String &spec, Array< String > &result, bool includeParentPath=false) |
list() directories More... | |
static void | getFiles (const String &spec, Array< String > &result, bool includeParentPath=false) |
list() files More... | |
static void | init () |
Create the common instance. More... | |
static bool | inZipfile (const String &path, String &zipfile, String &pathInZipfile) |
Returns true if some sub-path of path is a zipfile. More... | |
static bool | inZipfile (const String &path) |
Returns true if some sub-path of path is a zipfile. More... | |
static bool | isDirectory (const String &path, bool expandEnvironmentVariablesInPath=true) |
Known bug: does not work inside zipfiles. More... | |
static bool | isFile (const String &path) |
Known bug: does not work inside zipfiles. More... | |
static bool | isNewer (const String &src, const String &dst) |
Returns true if dst does not exist or src is newer than dst, according to their time stamps. More... | |
static bool | isPasswordProtected (const String &zipFile, String &password) |
If true, returns the password in the second parameter. More... | |
static bool | isZipfile (const String &path) |
Returns true if path is a file that is a zipfile. More... | |
static void | list (const String &spec, Array< String > &result, const ListSettings &listSettings=ListSettings()) |
Appends all nodes matching spec to the result array. More... | |
static void | markFileUsed (const String &filename) |
Adds filename to usedFiles(). More... | |
static String | NFDStandardizeFilename (const String &path, const String &cwd=currentDirectory()) |
Attempts to fully resolve a filename, removing all instances of "." and "..", assuming that there are no Symlinks that would make "." or ".." difficult to reason about. More... | |
static bool | registerPasswordProtectedZip (const String &zipFile, const String &password) |
Add a zipfile and password to FileSystem registry. More... | |
static void | removeFile (const String &path) |
Delete this file. More... | |
static int | rename (const String &src, const String &dst) |
static String | resolve (const String &path, const String &cwd=currentDirectory()) |
Fully qualifies a filename. More... | |
static void | setMarkFileUsedEnabled (bool enabled) |
Sets whether markFileUsed is enabled. More... | |
static int64 | size (const String &path) |
Returns the length of the file in bytes, or -1 if the file could not be opened. More... | |
static String | tempFilename (const String &basePath=".") |
Creates a unique name for a temporary file. More... | |
static const Set< String > & | usedFiles () |
All files that have been marked by markFileUsed(). More... | |
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.
|
inlinestatic |
A cache is used to optimize repeated calls.
A cache entry is considered valid for this many seconds after it has been checked.
|
static |
Destroy the common instance.
|
inlinestatic |
|
static |
Clears list of used files marked by markFileUsed().
|
inlinestatic |
srcPath | Must name a directory or zipfile. |
dstPath | Must name a directory |
Flushes the cache.
|
inlinestatic |
srcPath | Must name a file. |
dstPath | Must not contain a zipfile. |
Flushes the cache.
|
inlinestatic |
Creates the directory named, including any subdirectories that do not already exist.
The directory must not be inside a zipfile.
Flushes the cache.
|
inlinestatic |
The current working directory (cwd).
Only ends in a slash if this is the root of the file system.
On Windows, the drive letters that form the file system roots.
|
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. |
|
inlinestatic |
|
inlinestatic |
Same as the C standard library fopen, but updates the file cache to acknowledge the new file on a write operation.
|
inlinestatic |
list() directories
|
inlinestatic |
list() files
|
static |
Create the common instance.
|
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, if the function returned true |
pathInZipfile | The path within the zipfile to the named file, if the function returned true |
|
inlinestatic |
Returns true if some sub-path of path is a zipfile.
If the path itself is a zipfile, returns false.
|
inlinestatic |
Known bug: does not work inside zipfiles.
|
inlinestatic |
Known bug: does not work inside zipfiles.
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.
|
static |
If true, returns the password in the second parameter.
|
inlinestatic |
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"
|
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).
|
static |
Adds filename to usedFiles().
This is called automatically by open() and all G3D routines that open files. Is thread-safe to call.
|
inlinestatic |
Attempts to fully resolve a filename, removing all instances of "." and "..", assuming that there are no Symlinks that would make "." or ".." difficult to reason about.
Also ensures that the slashes are consistent. NFD will crash when given a path that does not meet this qualifications
|
static |
Add a zipfile and password to FileSystem registry.
|
inlinestatic |
Delete this file.
No effect if path does not exist.
path | May contain wildcards. May not be inside a zipfile. |
|
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) |
|
inline |
Set the cacheLifetime().
t | in seconds |
|
static |
Sets whether markFileUsed is enabled.
Files are not marked when disabled
Returns the length of the file in bytes, or -1 if the file could not be opened.
Creates a unique name for a temporary file.
This is on FileSystem instead of FilePath because it must check the actual filesystem for name conflicts.
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. Not thread-safe to use.