Torque::FS

Engine/source/core/virtualMountSystem.cpp

More...

Classes:

class

Base class for all FileIO objects.

class

Base class for objects in a FileSystem.

class

Collection of FileNode objects.

class

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.

Create a file.

Create a directory.

Open a file.

bool
ReadFile(const Path & inPath, void *& outData, U32 & outSize, bool inNullTerminate)

Read in an entire file.

Open a directory.

bool
Remove(const Path & path)

Remove (or delete) a file from the file system.

bool
Rename(const Path & from, const Path & to)

Rename a file or directory.

bool

Mount file system.

bool
Mount(String root, const Path & path)

Mount file system redirect.

Remove mounted file system.

bool

Remove mounted file system.

bool
SetCwd(const Path & file)

Set current working directory.

Get the current working directory.

Find the the file system which owns the given file.

bool

Get the file attributes.

Compare modified times of p1 & p2.

Find the file system node for the given file.

bool
MapFSPath(const String & inRoot, const Path & inPath, Path & outPath)

Map a real file system path to a virtual one based on a root.

bool
GetFSPath(const Path & inPath, Path & outPath)

Returns a true file system path without virtual mounts.

FindByPattern(const Path & inBasePath, const String & inFilePattern, bool inRecursive, Vector< String > & outList, bool multiMatch)

Find files matching a pattern starting in a given dir.

bool
IsFile(const Path & path)
bool
bool
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.

bool

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.

Public Typedefs

DirectoryPtr 
DirectoryRef 
FileNodePtr 
FileNodeRef 
FilePtr 
FileRef 
FileSystemPtr 
FileSystemRef 

Public Variables

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.

return:

Null if the file does not exist

ReadFile(const Path & inPath, void *& outData, U32 & outSize, bool inNullTerminate)

Read in an entire file.

note:

Caller is responsible for freeing memory

Parameters:
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

return:

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.

return:

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.

return:

The unmounted file system.

Unmount(FileSystemRef fs)

Remove mounted file system.

Open files associated with this file system are unaffected.

return:

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.

return:

success

CompareModifiedTimes(const Path & p1, const Path & p2)

Compare modified times of p1 & p2.

return:

-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.

return:

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

return:

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?

return:

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 

Public Variables

bool gVMSVerboseLog