ScummVM API documentation
Common::SearchSet Class Reference

#include <archive.h>

Inheritance diagram for Common::SearchSet:
Common::Archive Common::SearchManager Drascula::ArchiveMan

Public Member Functions

char getPathSeparator () const override
 
void add (const String &name, Archive *arch, int priority=0, bool autoFree=true)
 
void addDirectory (const String &name, const Path &directory, int priority=0, int depth=1, bool flat=false)
 
void addDirectory (const String &name, const FSNode &directory, int priority=0, int depth=1, bool flat=false)
 
void addDirectory (const Path &directory, int priority=0, int depth=1, bool flat=false)
 
void addDirectory (const FSNode &directory, int priority=0, int depth=1, bool flat=false)
 
void addSubDirectoryMatching (const FSNode &directory, const String &caselessName, int priority=0, int depth=1, bool flat=false)
 
void addSubDirectoriesMatching (const FSNode &directory, String origPattern, bool ignoreCase, int priority=0, int depth=1, bool flat=false)
 
void remove (const String &name)
 
bool hasArchive (const String &name) const
 
Archive * getArchive (const String &name) const
 
virtual void clear ()
 
void setPriority (const String &name, int priority)
 
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 listMatchingMembers (ArchiveMemberDetailsList &list, const Path &pattern, bool matchPathComponents=false) const
 
int listMembers (ArchiveMemberList &list) const override
 
const ArchiveMemberPtr getMember (const Path &path) const override
 
const ArchiveMemberPtr getMember (const Path &path, Archive **container) const
 
SeekableReadStream * createReadStreamForMember (const Path &path) const override
 
SeekableReadStream * createReadStreamForMemberAltStream (const Path &path, AltStreamType altStreamType) const override
 
SeekableReadStream * createReadStreamForMemberNext (const Path &path, const Archive *starting) const override
 
void setIgnoreClashes (bool ignoreClashes)
 
bool getChildren (const Common::Path &path, Common::Array< Common::String > &list, ListMode mode=kListDirectoriesOnly, bool hidden=true) const override
 
- Public Member Functions inherited from Common::Archive
virtual bool hasFile (const Path &path) const =0
 
virtual bool isPathDirectory (const Path &path) const
 
virtual int listMatchingMembers (ArchiveMemberList &list, const Path &pattern, bool matchPathComponents=false) const
 
virtual int listMembers (ArchiveMemberList &list) const =0
 
virtual const ArchiveMemberPtr getMember (const Path &path) const =0
 
virtual SeekableReadStream * createReadStreamForMember (const Path &path) const =0
 
virtual SeekableReadStream * createReadStreamForMemberAltStream (const Path &path, AltStreamType altStreamType) const
 
virtual SeekableReadStream * createReadStreamForMemberNext (const Path &path, const Archive *starting) const
 
Common::Error dumpArchive (const Path &destPath)
 
virtual char getPathSeparator () const
 
virtual bool getChildren (const Common::Path &path, Common::Array< Common::String > &list, ListMode mode=kListDirectoriesOnly, bool hidden=true) const
 

Additional Inherited Members

- Public Types inherited from Common::Archive
enum  ListMode { kListFilesOnly = 1 , kListDirectoriesOnly = 2 , kListAll = 3 }
 

Detailed Description

The SearchSet class enables access to a group of Archives through the Archive interface.

Its intended usage is a situation in which there are no name clashes among names in the contained Archives, hence the simplistic policy of always looking for the first match. SearchSet does guarantee that searches are performed in DESCENDING priority order. In case of conflicting priorities, insertion order prevails.

Member Function Documentation

◆ getPathSeparator()

char Common::SearchSet::getPathSeparator ( ) const
inlineoverridevirtual

Returns the separator used by internal paths in the archive

Reimplemented from Common::Archive.

◆ add()

void Common::SearchSet::add ( const String &  name,
Archive *  arch,
int  priority = 0,
bool  autoFree = true 
)

Add a new archive to the searchable set.

◆ addDirectory() [1/3]

void Common::SearchSet::addDirectory ( const String &  name,
const Path &  directory,
int  priority = 0,
int  depth = 1,
bool  flat = false 
)

Create and add an FSDirectory by name.

◆ addDirectory() [2/3]

void Common::SearchSet::addDirectory ( const String &  name,
const FSNode &  directory,
int  priority = 0,
int  depth = 1,
bool  flat = false 
)

Create and add an FSDirectory by FSNode.

◆ addDirectory() [3/3]

void Common::SearchSet::addDirectory ( const Path &  directory,
int  priority = 0,
int  depth = 1,
bool  flat = false 
)

Overloads which use directory path as name

◆ addSubDirectoryMatching()

void Common::SearchSet::addSubDirectoryMatching ( const FSNode &  directory,
const String &  caselessName,
int  priority = 0,
int  depth = 1,
bool  flat = false 
)
inline

Create and add a subdirectory by name (caseless).

It is also possible to add subdirectories of subdirectories (of any depth) with this function. The path separator for this case is SLASH for all systems.

Example:

"game/itedata"

In this example, the code first tries to search for all directories matching "game" (case insensitive) in the path "directory" first and search through all of the matches for "itedata" (case insensitive too).

Note that it will add all matches found!

Even though this method is currently implemented via addSubDirectoriesMatching, it is not safe to assume that this method is using anything other than a simple case insensitive compare. Thus, do not use any tokens like '*' or '?' in the "caselessName" parameter of this function.

◆ addSubDirectoriesMatching()

void Common::SearchSet::addSubDirectoriesMatching ( const FSNode &  directory,
String  origPattern,
bool  ignoreCase,
int  priority = 0,
int  depth = 1,
bool  flat = false 
)

Create and add subdirectories by pattern.

It is also possible to add subdirectories of subdirectories (of any depth) with this function. The path separator for this case is SLASH for all systems.

Example:

"game/itedata"

In this example, the code first tries to search for all directories matching "game" in the path "directory" first and search through all of the matches for "itedata". If "ignoreCase" is set to true, the code does a case insensitive match, otherwise it is doing a case sensitive match.

This method also works with tokens. For a list of available tokens, see Common::matchString.

◆ remove()

void Common::SearchSet::remove ( const String &  name)

Remove an archive from the searchable set.

◆ hasArchive()

bool Common::SearchSet::hasArchive ( const String &  name) const

Check if a given archive name is already present.

◆ getArchive()

Archive * Common::SearchSet::getArchive ( const String &  name) const

Looks up an archive in the searchable set.

◆ clear()

virtual void Common::SearchSet::clear ( )
virtual

Empty the searchable set.

Reimplemented in Common::SearchManager.

◆ setPriority()

void Common::SearchSet::setPriority ( const String &  name,
int  priority 
)

Change the order of searches.

◆ hasFile()

bool Common::SearchSet::hasFile ( const Path &  path) const
overridevirtual

Check if a member with the given name is present in the Archive. Patterns are not allowed, as this is meant to be a quick File::exists() replacement. This returns "true" for both files and directories.

Implements Common::Archive.

◆ isPathDirectory()

bool Common::SearchSet::isPathDirectory ( const Path &  path) const
overridevirtual

Check if a member with the given name exists and is a directory.

Reimplemented from Common::Archive.

◆ listMatchingMembers()

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

Add all members of the Archive matching the specified pattern to the list. Must only append to list, and not remove elements from it.

Parameters
matchPathComponentsif set, then whole string will be matched, otherwise (default), path separator ('/') does not match with wildcards
Returns
The number of members added to list.

Reimplemented from Common::Archive.

◆ listMembers()

int Common::SearchSet::listMembers ( ArchiveMemberList &  list) const
overridevirtual

Add all members of the Archive to the list. Must only append to list, and not remove elements from it.

Returns
The number of names added to list.

Implements Common::Archive.

◆ getMember()

const ArchiveMemberPtr Common::SearchSet::getMember ( const Path &  path) const
overridevirtual

Return an ArchiveMember representation of the given file.

Implements Common::Archive.

◆ createReadStreamForMember()

SeekableReadStream * Common::SearchSet::createReadStreamForMember ( const Path &  path) const
overridevirtual

Implement createReadStreamForMember from the Archive base class. The current policy is opening the first file encountered that matches the name.

Implements Common::Archive.

◆ createReadStreamForMemberAltStream()

SeekableReadStream * Common::SearchSet::createReadStreamForMemberAltStream ( const Path &  path,
AltStreamType  altStreamType 
) const
overridevirtual

Implement createReadStreamForMemberAltStream from the Archive base class. The current policy is opening the first file encountered that matches the name.

Reimplemented from Common::Archive.

◆ createReadStreamForMemberNext()

SeekableReadStream * Common::SearchSet::createReadStreamForMemberNext ( const Path &  path,
const Archive *  starting 
) const
overridevirtual

Similar to above but exclude matches from archives before starting and starting itself.

Reimplemented from Common::Archive.

◆ setIgnoreClashes()

void Common::SearchSet::setIgnoreClashes ( bool  ignoreClashes)
inline

Ignore clashes when adding directories. For more details, see the corresponding parameter in FSDirectory documentation.

◆ getChildren()

bool Common::SearchSet::getChildren ( const Common::Path &  path,
Common::Array< Common::String > &  list,
ListMode  mode = kListDirectoriesOnly,
bool  hidden = true 
) const
overridevirtual

Reimplemented from Common::Archive.


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