#include <fs.h>
Public Member Functions | |
FSDirectory (const Path &name, int depth=1, bool flat=false, bool ignoreClashes=false, bool includeDirectories=false) | |
FSDirectory (const FSNode &node, int depth=1, bool flat=false, bool ignoreClashes=false, bool includeDirectories=false) | |
FSDirectory (const Path &prefix, const Path &name, int depth=1, bool flat=false, bool ignoreClashes=false, bool includeDirectories=false) | |
FSDirectory (const Path &prefix, const FSNode &node, int depth=1, bool flat=false, bool ignoreClashes=false, bool includeDirectories=false) | |
FSNode | getFSNode () const |
FSDirectory * | getSubDirectory (const Path &name, int depth=1, bool flat=false, bool ignoreClashes=false) |
FSDirectory * | getSubDirectory (const Path &prefix, const Path &name, int depth=1, bool flat=false, bool ignoreClashes=false) |
bool | hasFile (const Path &path) const override |
bool | isPathDirectory (const Path &path) const override |
int | listMatchingMembers (ArchiveMemberList &list, const Path &pattern, bool matchPathComponents=false) const override |
int | listMembers (ArchiveMemberList &list) const override |
const ArchiveMemberPtr | getMember (const Path &path) const override |
SeekableReadStream * | createReadStreamForMember (const Path &path) const override |
SeekableReadStream * | createReadStreamForMemberAltStream (const Path &path, AltStreamType altStreamType) const override |
Public Member Functions inherited from Common::Archive | |
virtual SeekableReadStream * | createReadStreamForMemberNext (const Path &path, const Archive *starting) const |
Common::Error | dumpArchive (const Path &destPath) |
virtual char | getPathSeparator () const |
FSDirectory models a directory tree from the file system and allows users to access it through the Archive interface. Searching is case-insensitive, since the intended goal is to support retrieval of game data.
FSDirectory can represent a single directory, or a tree with specified depth, depending on the value passed to the 'depth' parameter in the constructors. In the default mode, file names are cached with their relative path, with elements separated by slashes, e.g.:
would be cached as 'data/file.ext' if FSDirectory was created on 'c:/my' with depth > 1. If depth was 1, then the 'data' subdirectory would have been ignored, instead. Again, only SLASHES are used as separators independently from the underlying file system.
Relative paths can be specified when calling matching functions like createReadStreamForMember(), hasFile(), listMatchingMembers(), and listMembers(). See the function-specific documentation for more information.
If the 'flat' argument to the constructor is true, files in subdirectories are cached without the relative path, so in the following example:
would be cached as 'file.ext'.
When the 'ignoreClashes' argument to the constructor is true, name clashes are expected by the engine. It means that files that clash should be identical and getSubDirectory should not be used on clashing directories. This flag is useful in flat mode when there are directories with the same name at different places in the tree whose name is not relevant for the engine code.
Client code can customize the cache by using constructors with the 'prefix' parameter. In this case, the prefix is prepended to each entry in the cache, and effectively treated as a 'virtual' parent subdirectory. FSDirectory adds a trailing slash to the prefix if needed. Following on with the previous example and using 'your' as a prefix, the cache entry would have been 'your/data/file.ext'. This is done both in non-flat and flat mode.
Common::FSDirectory::FSDirectory | ( | const Path & | name, |
int | depth = 1 , |
||
bool | flat = false , |
||
bool | ignoreClashes = false , |
||
bool | includeDirectories = false |
||
) |
Create a FSDirectory representing a tree with the specified depth. Will result in an unbound FSDirectory if name is not found in the file system or if the node is not a valid directory.
Common::FSDirectory::FSDirectory | ( | const FSNode & | node, |
int | depth = 1 , |
||
bool | flat = false , |
||
bool | ignoreClashes = false , |
||
bool | includeDirectories = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Common::FSDirectory::FSDirectory | ( | const Path & | prefix, |
const Path & | name, | ||
int | depth = 1 , |
||
bool | flat = false , |
||
bool | ignoreClashes = false , |
||
bool | includeDirectories = false |
||
) |
Create a FSDirectory representing a tree with the specified depth. The parameter prefix is prepended to the keys in the cache. See FSDirectory.
Common::FSDirectory::FSDirectory | ( | const Path & | prefix, |
const FSNode & | node, | ||
int | depth = 1 , |
||
bool | flat = false , |
||
bool | ignoreClashes = false , |
||
bool | includeDirectories = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
FSNode Common::FSDirectory::getFSNode | ( | ) | const |
Return the underlying FSNode of the FSDirectory.
FSDirectory* Common::FSDirectory::getSubDirectory | ( | const Path & | name, |
int | depth = 1 , |
||
bool | flat = false , |
||
bool | ignoreClashes = false |
||
) |
Create a new FSDirectory pointing to a subdirectory of the instance.
FSDirectory* Common::FSDirectory::getSubDirectory | ( | const Path & | prefix, |
const Path & | name, | ||
int | depth = 1 , |
||
bool | flat = false , |
||
bool | ignoreClashes = false |
||
) |
Create a new FSDirectory pointing to a subdirectory of the instance. See FSDirectory for an explanation of the prefix parameter.
|
overridevirtual |
Check for the existence of a file in the cache. A full match of relative path and file name is needed for success.
Implements Common::Archive.
|
overridevirtual |
Check if a specified subpath is a directory.
Reimplemented from Common::Archive.
|
overridevirtual |
Return a list of matching file names. Pattern can use GLOB wildcards.
Reimplemented from Common::Archive.
|
overridevirtual |
Return a list of all the files in the cache.
Implements Common::Archive.
|
overridevirtual |
Get an ArchiveMember representation of the specified file. A full match of relative path and file name is needed for success.
Implements Common::Archive.
|
overridevirtual |
Open the specified file. A full match of relative path and file name is needed for success.
Implements Common::Archive.
|
overridevirtual |
Open an alternate stream for a specified file. A full match of relative path and file name is needed for success.
Reimplemented from Common::Archive.