Volume System

Volume access.

More...

Classes:

class

Base class for all FileIO objects.

class

Base class for objects in a FileSystem.

class

Collection of FileNode objects.

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.

bool
Mount(String root, FileSystemRef fs)

Mount file system.

bool
Mount(String root, const Path & path)

Mount file system redirect.

FileSystemRef

Remove mounted file system.

FileSystemRef
GetFileSystem(const Path & path)

Find the the file system which owns the given file.

FileNodeRef
GetFileNode(const Path & path)

Find the file system node for the given file.

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.

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
SetCwd(const Path & file)

Set current working directory.

const Path &

Get the current working 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
GetFileAttributes(const Path & path, FileNode::Attributes * attr)

Get the file attributes.

FileRef
OpenFile(const Path & file, File::AccessMode mode)

Open a file.

DirectoryRef
OpenDirectory(const Path & file)

Open a directory.

FileRef
CreateFile(const Path & file)

Create a file.

DirectoryRef
CreateDirectory(const Path & file)

Create a directory.

bool
CreatePath(const Path & path)

Create all the directories in the path if they don't already exist.

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

Read in an entire file.

bool
Unmount(FileSystemRef fs)

Remove mounted file system.

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

Compare modified times of p1 & p2.

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.

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

bool
VerifyWriteAccess(const Path & path)

Functions

Convert file/path name to use OS standard path separator.

Convert file/path name to use platform standard path separator.

Detailed Description

Volume access.

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.

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.

GetFileSystem(const Path & path)

Find the the file system which owns the given file.

GetFileNode(const Path & path)

Find the file system node for the given file.

return:

Null if the file doesn't 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.

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

SetCwd(const Path & file)

Set current working directory.

GetCwd()

Get the current working directory.

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.

GetFileAttributes(const Path & path, FileNode::Attributes * attr)

Get the file attributes.

return:

success

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

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

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.

CreatePath(const Path & path)

Create all the directories in the path if they don't already 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

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)

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

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.

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)

VerifyWriteAccess(const Path & path)

Functions

PathToOS(String file)

Convert file/path name to use OS standard path separator.

PathToPlatform(String file)

Convert file/path name to use platform standard path separator.