ScummVM API documentation
Common::FSDirectory Class Reference

#include <fs.h>

Inheritance diagram for Common::FSDirectory:
Common::Archive

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
 
FSDirectorygetSubDirectory (const Path &name, int depth=1, bool flat=false, bool ignoreClashes=false)
 
FSDirectorygetSubDirectory (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
 
SeekableReadStreamcreateReadStreamForMember (const Path &path) const override
 
SeekableReadStreamcreateReadStreamForMemberAltStream (const Path &path, AltStreamType altStreamType) const override
 
- Public Member Functions inherited from Common::Archive
virtual SeekableReadStreamcreateReadStreamForMemberNext (const Path &path, const Archive *starting) const
 
Common::Error dumpArchive (const Path &destPath)
 
virtual char getPathSeparator () const
 

Detailed Description

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

c:\my\data\file.ext

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:

c:\my\data\file.ext

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.

Constructor & Destructor Documentation

◆ FSDirectory() [1/4]

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.

◆ FSDirectory() [2/4]

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.

◆ FSDirectory() [3/4]

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.

◆ FSDirectory() [4/4]

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.

Member Function Documentation

◆ getFSNode()

FSNode Common::FSDirectory::getFSNode ( ) const

Return the underlying FSNode of the FSDirectory.

◆ getSubDirectory() [1/2]

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.

Returns
A new FSDirectory instance.

◆ getSubDirectory() [2/2]

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.

Returns
A new FSDirectory instance.

◆ hasFile()

bool Common::FSDirectory::hasFile ( const Path path) const
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.

◆ isPathDirectory()

bool Common::FSDirectory::isPathDirectory ( const Path path) const
overridevirtual

Check if a specified subpath is a directory.

Reimplemented from Common::Archive.

◆ listMatchingMembers()

int Common::FSDirectory::listMatchingMembers ( ArchiveMemberList list,
const Path pattern,
bool  matchPathComponents = false 
) const
overridevirtual

Return a list of matching file names. Pattern can use GLOB wildcards.

Reimplemented from Common::Archive.

◆ listMembers()

int Common::FSDirectory::listMembers ( ArchiveMemberList list) const
overridevirtual

Return a list of all the files in the cache.

Implements Common::Archive.

◆ getMember()

const ArchiveMemberPtr Common::FSDirectory::getMember ( const Path path) const
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.

◆ createReadStreamForMember()

SeekableReadStream* Common::FSDirectory::createReadStreamForMember ( const Path path) const
overridevirtual

Open the specified file. A full match of relative path and file name is needed for success.

Implements Common::Archive.

◆ createReadStreamForMemberAltStream()

SeekableReadStream* Common::FSDirectory::createReadStreamForMemberAltStream ( const Path path,
AltStreamType  altStreamType 
) const
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.


The documentation for this class was generated from the following file: