xoreos  0.0.5
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
Common::FileList Class Reference

A list of files. More...

#include <filelist.h>

Collaboration diagram for Common::FileList:
Collaboration graph
[legend]

Public Types

typedef std::list< UString >::const_iterator const_iterator
 

Public Member Functions

 FileList ()
 
 FileList (const FileList &list)
 
 FileList (const UString &directory, int recurseDepth=0)
 Construct a list with the contents of this directory. More...
 
 ~FileList ()
 
FileListoperator= (const FileList &list)
 
FileListoperator+= (const FileList &list)
 
void clear ()
 Clear the list. More...
 
bool empty () const
 Is the list empty? More...
 
size_t size () const
 Return the number of files in the list. More...
 
void sort (bool caseInsensitive)
 Sort this list alphabetically. More...
 
void relativize (const Common::UString &basePath)
 Express all files in this archive as relative to the given base path. More...
 
const_iterator begin () const
 Return a const_iterator pointing to the beginning of the list. More...
 
const_iterator end () const
 Return a const_iterator pointing past the end of the list. More...
 
bool addDirectory (const UString &directory, int recurseDepth=0)
 Add a directory to the list. More...
 
bool addSubDirectories (const UString &directory)
 Add subdirectories of a directory to the list. More...
 
bool getSubList (const UString &str, bool caseInsensitive, FileList &subList) const
 Add files ending with the given string into another FileList. More...
 
bool getSubListGlob (const UString &glob, bool caseInsensitive, FileList &subList) const
 Add files matching the given regex into another FileList. More...
 
bool contains (const UString &str, bool caseInsensitive) const
 Does the list contain at least one file ending with the given string? More...
 
bool containsGlob (const UString &glob, bool caseInsensitive) const
 Does the list contain at least one file matching the given regex? More...
 
UString findFirst (const UString &str, bool caseInsensitive) const
 Find the first file ending with the given string. More...
 
UString findFirstGlob (const UString &glob, bool caseInsensitive) const
 Find the first file matching the given regex. More...
 

Private Types

typedef std::list< UStringFiles
 

Private Attributes

Files _files
 

Detailed Description

A list of files.

Definition at line 35 of file filelist.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 37 of file filelist.h.

◆ Files

typedef std::list<UString> Common::FileList::Files
private

Definition at line 141 of file filelist.h.

Constructor & Destructor Documentation

◆ FileList() [1/3]

Common::FileList::FileList ( )

Definition at line 36 of file filelist.cpp.

◆ FileList() [2/3]

Common::FileList::FileList ( const FileList list)

Definition at line 43 of file filelist.cpp.

◆ FileList() [3/3]

Common::FileList::FileList ( const UString directory,
int  recurseDepth = 0 
)

Construct a list with the contents of this directory.

See addDirectory().

Definition at line 39 of file filelist.cpp.

References addDirectory().

Here is the call graph for this function:

◆ ~FileList()

Common::FileList::~FileList ( )

Definition at line 47 of file filelist.cpp.

Member Function Documentation

◆ addDirectory()

bool Common::FileList::addDirectory ( const UString directory,
int  recurseDepth = 0 
)

◆ addSubDirectories()

bool Common::FileList::addSubDirectories ( const UString directory)

Add subdirectories of a directory to the list.

Parameters
directoryThe directory to scan.
Returns
true if the subdirectories were successfully added to the list, false otherwise.

Definition at line 131 of file filelist.cpp.

References _files, Common::UString::c_str(), Common::FilePath::canonicalize(), and Common::FilePath::isDirectory().

Referenced by Engines::KotOR::SaveLoadMenu::addSavedGameItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin()

FileList::const_iterator Common::FileList::begin ( ) const

◆ clear()

void Common::FileList::clear ( )

Clear the list.

Definition at line 62 of file filelist.cpp.

References _files.

◆ contains()

bool Common::FileList::contains ( const UString str,
bool  caseInsensitive 
) const

◆ containsGlob()

bool Common::FileList::containsGlob ( const UString glob,
bool  caseInsensitive 
) const

Does the list contain at least one file matching the given regex?

Parameters
globA perl regular expression to match the file names against.
caseInsensitiveShould the case of the file name be ignored?
Returns
true if at least one matching file is found, false otherwise.

Definition at line 189 of file filelist.cpp.

References Common::UString::empty(), and findFirstGlob().

Referenced by Engines::Witcher::EngineProbe::probe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

bool Common::FileList::empty ( ) const

Is the list empty?

Definition at line 66 of file filelist.cpp.

References _files.

◆ end()

FileList::const_iterator Common::FileList::end ( ) const

◆ findFirst()

UString Common::FileList::findFirst ( const UString str,
bool  caseInsensitive 
) const

Find the first file ending with the given string.

Parameters
strA file ending to match file names against.
caseInsensitiveShould the case of the file name be ignored?
Returns
The path of the first matching file, or "" if such a file is not in the list.

Definition at line 193 of file filelist.cpp.

References _files, Common::UString::endsWith(), and Common::UString::toLower().

Referenced by contains(), Engines::KotOR2::KotOR2Engine::detectLanguages(), Engines::NWN2::NWN2Engine::detectLanguages(), Engines::KotOR::KotOREngine::detectLanguages(), Engines::NWN::NWNEngine::detectLanguages(), Engines::DragonAge::Campaigns::findCampaigns(), Engines::DragonAge2::Campaigns::findCampaigns(), Engines::NWN2::Campaign::getDescription(), Engines::NWN2::Campaign::getName(), Engines::KotOR::Version::readFile(), and Engines::NWN::Version::readFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findFirstGlob()

UString Common::FileList::findFirstGlob ( const UString glob,
bool  caseInsensitive 
) const

Find the first file matching the given regex.

Parameters
globA perl regular expression to match the file names against.
caseInsensitiveShould the case of the file name be ignored?
Returns
The path of the first matching file, or "" if such a file is not in the list.

Definition at line 207 of file filelist.cpp.

References _files, and Common::UString::c_str().

Referenced by containsGlob(), Engines::DragonAge2::Campaigns::findCampaigns(), and Engines::DragonAge::Campaigns::findCampaigns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSubList()

bool Common::FileList::getSubList ( const UString str,
bool  caseInsensitive,
FileList subList 
) const

Add files ending with the given string into another FileList.

Parameters
strA file ending to match file names against.
caseInsensitiveShould the case of the file name be ignored?
subListThe FileList to where to add the matching files.
Returns
true if at least one matching file was found.

Definition at line 149 of file filelist.cpp.

References _files, Common::UString::endsWith(), and Common::UString::toLower().

Referenced by Engines::Jade::findTLKs(), and Engines::Witcher::Console::updateMusic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSubListGlob()

bool Common::FileList::getSubListGlob ( const UString glob,
bool  caseInsensitive,
FileList subList 
) const

Add files matching the given regex into another FileList.

Parameters
globA perl regular expression to match the file names against.
caseInsensitiveShould the case of the file name be ignored?
subListThe FileList to where to add the matching files.
Returns
true if at least one matching file was found.

Definition at line 167 of file filelist.cpp.

References _files, and Common::UString::c_str().

Referenced by Aurora::ResourceManager::indexResourceDir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator+=()

FileList & Common::FileList::operator+= ( const FileList list)

Definition at line 56 of file filelist.cpp.

References _files.

◆ operator=()

FileList & Common::FileList::operator= ( const FileList list)

Definition at line 50 of file filelist.cpp.

References _files.

◆ relativize()

void Common::FileList::relativize ( const Common::UString basePath)

Express all files in this archive as relative to the given base path.

Files that do not match the base path will be removed from the list. See also FilePath::relativize().

Definition at line 81 of file filelist.cpp.

References _files, and Common::FilePath::relativize().

Referenced by Engines::DragonAge::Game::loadResourceDir(), Engines::DragonAge2::Game::loadResourceDir(), and Engines::DragonAge2::Game::loadResources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

size_t Common::FileList::size ( ) const

Return the number of files in the list.

Definition at line 70 of file filelist.cpp.

References _files.

◆ sort()

void Common::FileList::sort ( bool  caseInsensitive)

Sort this list alphabetically.

Definition at line 74 of file filelist.cpp.

References _files.

Referenced by Engines::KotOR::SaveLoadMenu::addSavedGameItems(), Engines::DragonAge::Game::loadResourceDir(), and Engines::DragonAge2::Game::loadResourceDir().

Here is the caller graph for this function:

Member Data Documentation

◆ _files

Files Common::FileList::_files
private

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