Torque::FS
Engine/source/core/virtualMountSystem.cpp
Classes:
File object in a FileSystem.
Base class for all FileIO objects.
Base class for objects in a FileSystem.
Collection of FileNode objects.
The VirtualMountSystem extend the mount system by allowing you to mount and access multiple filesystems on a single root.
File System Access
Functions for mounting file systems and dealing with files and directories.
The kernel provides FileSystem mounting, the concept of a current working directory as well as relative paths.
CreateFile(const Path & file)
Create a file.
CreateDirectory(const Path & file)
Create a directory.
OpenFile(const Path & file, File::AccessMode mode)
Open a file.
bool
OpenDirectory(const Path & file)
Open a directory.
bool
Mount(String root, FileSystemRef fs)
Mount file system.
bool
Unmount(FileSystemRef fs)
Remove mounted file system.
GetFileSystem(const Path & path)
Find the the file system which owns the given file.
bool
GetFileAttributes(const Path & path, FileNode::Attributes * attr)
Get the file attributes.
GetFileNode(const Path & path)
Find the file system node for the given file.
bool
bool
bool
IsDirectory(const Path & path)
bool
IsReadOnly(const Path & path)
MakeUniquePath(const char * path, const char * fileName, const char * ext)
This returns a unique file path from the components by appending numbers to the end of the file name if a file with the same name already exists.
GetMountRoot(S32 index)
GetMountPath(S32 index)
GetMountType(S32 index)
bool
CreatePath(const Path & path)
Create all the directories in the path if they don't already exist.
bool
AddChangeNotification(const Path & path, T obj, U func)
Adds a file change notification callback.
bool
RemoveChangeNotification(const Path & path, T obj, U func)
Removes an existing file change notification callback.
bool
VerifyWriteAccess(const Path & path)
Public Typedefs
DirectoryPtr
DirectoryRef
FileNodePtr
FileNodeRef
WeakRefPtr< File >
FilePtr
StrongRefPtr< File >
FileRef
FileSystemPtr
FileSystemRef
Public Variables
bool
Detailed Description
File System Access
Functions for mounting file systems and dealing with files and directories.
The kernel provides FileSystem mounting, the concept of a current working directory as well as relative paths.
CreateFile(const Path & file)
Create a file.
The file object is returned in a closed state.
CreateDirectory(const Path & file)
Create a directory.
The directory object is returned in a closed state.
OpenFile(const Path & file, File::AccessMode mode)
Open a file.
If the file exists a file object will be returned even if the open operation fails.
Null if the file does not exist
ReadFile(const Path & inPath, void *& outData, U32 & outSize, bool inNullTerminate)
Read in an entire file.
note:Parameters:Caller is responsible for freeing memory
inPath | the file |
outData | the pointer to return the data |
outSize | the size of the data returned |
inNullTerminate | add an extra '\0' byte to the return buffer |
successful read? If not, outData will be NULL and outSize will be 0
OpenDirectory(const Path & file)
Open a directory.
If the directory exists a directory object will be returned even if the open operation fails.
Null if the file does not exist
Remove(const Path & path)
Remove (or delete) a file from the file system.
Rename(const Path & from, const Path & to)
Rename a file or directory.
Mount(String root, FileSystemRef fs)
Mount file system.
Mount(String root, const Path & path)
Mount file system redirect.
Unmount(String root)
Remove mounted file system.
The file system object associated with the given root is unmounted. Open files associated with this file system are unaffected.
The unmounted file system.
Unmount(FileSystemRef fs)
Remove mounted file system.
Open files associated with this file system are unaffected.
true if the filesystem was successfully unmounted, false otherwise (most likely, the FS was not mounted)
SetCwd(const Path & file)
Set current working directory.
GetCwd()
Get the current working directory.
GetFileSystem(const Path & path)
Find the the file system which owns the given file.
GetFileAttributes(const Path & path, FileNode::Attributes * attr)
Get the file attributes.
success
CompareModifiedTimes(const Path & p1, const Path & p2)
Compare modified times of p1 & p2.
-1 if p1 < p2, 0 if p1 == p2, 1 if p1 > p2
GetFileNode(const Path & path)
Find the file system node for the given file.
Null if the file doesn't exist
MapFSPath(const String & inRoot, const Path & inPath, Path & outPath)
Map a real file system path to a virtual one based on a root.
This is useful when we get a real path back from an OS file dialog for example. e.g. If we have a root "gumby" which points at "C:/foo/bar", MapFSPath("gumby", "C:/foo/bar/blat/picture.png", path ); will map "C:/foo/bar/blat/picture.png" to "gumby:/blat/picture.png" Parameters:
inRoot | The root to check |
inPath | The real file system path |
outPath | The resulting volume system path |
Success or failure
GetFSPath(const Path & inPath, Path & outPath)
Returns a true file system path without virtual mounts.
Parameters:
inPath | The path to convert. |
outPath | The resulting real file system path. |
FindByPattern(const Path & inBasePath, const String & inFilePattern, bool inRecursive, Vector< String > & outList, bool multiMatch)
Find files matching a pattern starting in a given dir.
Parameters:
inBasePath | path to start in |
inFilePattern | the file pattern [it uses the FindMatch class] |
inRecursive | do we search recursively? |
outList | the list of files as Strings [Paths are more expensive to compute, so these may be converted on demand] |
multiMatch | match against multiple file patterns given in inFilePattern? |
number of files which matched
IsFile(const Path & path)
IsDirectory(const Path & path)
IsReadOnly(const Path & path)
MakeUniquePath(const char * path, const char * fileName, const char * ext)
This returns a unique file path from the components by appending numbers to the end of the file name if a file with the same name already exists.
Parameters:
path | The root and directory for the file. |
fileName | The file name without extension. |
ext | The dot-less extension. |
StartFileChangeNotifications()
StopFileChangeNotifications()
GetNumMounts()
GetMountRoot(S32 index)
GetMountPath(S32 index)
GetMountType(S32 index)
CreatePath(const Path & path)
Create all the directories in the path if they don't already exist.
AddChangeNotification(const Path & path, T obj, U func)
Adds a file change notification callback.
RemoveChangeNotification(const Path & path, T obj, U func)
Removes an existing file change notification callback.
VerifyWriteAccess(const Path & path)
Public Typedefs
typedef WeakRefPtr< Directory > DirectoryPtr
typedef StrongRefPtr< Directory > DirectoryRef
typedef WeakRefPtr< FileNode > FileNodePtr
typedef StrongRefPtr< FileNode > FileNodeRef
typedef WeakRefPtr< File > FilePtr
typedef StrongRefPtr< File > FileRef
typedef WeakRefPtr< FileSystem > FileSystemPtr
typedef StrongRefPtr< FileSystem > FileSystemRef