xoreos  0.0.5
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Aurora::ResourceManager Class Reference

A resource manager holding information about and handling all request for all resources usable by the game. More...

#include <resman.h>

Inheritance diagram for Aurora::ResourceManager:
Inheritance graph
[legend]
Collaboration diagram for Aurora::ResourceManager:
Collaboration graph
[legend]

Classes

class  Change
 
struct  ChangeSet
 A set of changes produced by a manager operation. More...
 
struct  KnownArchive
 
struct  OpenedArchive
 
struct  Resource
 A resource. More...
 
struct  ResourceChange
 A change produced by indexing archive resources. More...
 
struct  ResourceID
 

Public Member Functions

 ResourceManager ()
 
 ~ResourceManager ()
 
void clear ()
 Clear all resource information. More...
 
void setRIMsAreERFs (bool rimsAreERFs)
 Are .rim/.rimp files actually ERF files? More...
 
void setHasSmall (bool hasSmall)
 Do we have "small" files (compressed with Nintendo DS's LZSS algorithm)? More...
 
void setHashAlgo (Common::HashAlgo algo)
 With which hash algorithm are/should the names be hashed? More...
 
void setCursorRemap (const std::vector< Common::UString > &remap)
 Set the array used to map cursor ID to cursor names. More...
 
void addTypeAlias (FileType alias, FileType realType)
 Add an alias for one file type to another. More...
 
void registerDataBase (const Common::UString &path)
 Register a path to be the data base. More...
 
const Common::UStringgetDataBase () const
 Return the path of the currently registered base data directory or archive. More...
 
bool hasArchive (const Common::UString &file)
 Does a specific archive exist? More...
 
void indexArchive (const Common::UString &file, uint32 priority, Common::ChangeID *changeID=0)
 Add all the resources of an archive to the resource manager. More...
 
void indexArchive (const Common::UString &file, uint32 priority, const std::vector< byte > &password, Common::ChangeID *changeID=0)
 Add all the resources of an archive to the resource manager. More...
 
bool hasResourceDir (const Common::UString &dir)
 Does a specific directory, relative to the base directory, exist? More...
 
void indexResourceFile (const Common::UString &file, uint32 priority, Common::ChangeID *changeID=0)
 Add a single file to the resource manager. More...
 
void indexResourceDir (const Common::UString &dir, const char *glob, int depth, uint32 priority, Common::ChangeID *changeID=0)
 Add a directory's contents to the resource manager. More...
 
void undo (Common::ChangeID &changeID)
 Undo the changes done in the specified change ID. More...
 
void blacklist (const Common::UString &name, FileType type)
 Blacklist a specific resource. More...
 
void declareResource (const Common::UString &name, FileType type)
 Declare the name of a specific resource. More...
 
void declareResource (const Common::UString &name)
 Declare the name of a specific resource. More...
 
bool hasResource (uint64 hash) const
 Does a specific resource exist? More...
 
bool hasResource (const Common::UString &name, FileType type) const
 Does a specific resource exist? More...
 
bool hasResource (const Common::UString &name, ResourceType type) const
 Does a specific resource exist? More...
 
bool hasResource (const Common::UString &name) const
 Does a specific resource exist? More...
 
bool hasResource (const Common::UString &name, const std::vector< FileType > &types) const
 Does a specific resource exist? More...
 
Common::UString findResourceFile (const Common::UString &name, FileType type) const
 Find and return the absolute filesystem file behind a resource. More...
 
Common::UString findResourceFile (const Common::UString &name, ResourceType type) const
 Find and return the absolute filesystem file behind a resource. More...
 
Common::UString findResourceFile (const Common::UString &name) const
 Find and return the absolute filesystem file behind a resource. More...
 
Common::UString findResourceFile (const Common::UString &name, const std::vector< FileType > &types) const
 Find and return the absolute filesystem file behind a resource. More...
 
Common::SeekableReadStreamgetResource (uint64 hash, FileType *type=0) const
 Return a resource. More...
 
Common::SeekableReadStreamgetResource (const Common::UString &name, FileType type) const
 Return a resource. More...
 
Common::SeekableReadStreamgetResource (const Common::UString &name) const
 Return a resource. More...
 
Common::SeekableReadStreamgetResource (const Common::UString &name, const std::vector< FileType > &types, FileType *foundType=0) const
 Return a resource. More...
 
Common::SeekableReadStreamgetResource (ResourceType resType, const Common::UString &name, FileType *foundType=0) const
 Return a resource of a specific type. More...
 
void getAvailableResources (FileType type, std::list< ResourceID > &list) const
 Return a list of all available resources of the specified type. More...
 
void getAvailableResources (const std::vector< FileType > &types, std::list< ResourceID > &list) const
 Return a list of all available resources of the specified type. More...
 
void getAvailableResources (ResourceType type, std::list< ResourceID > &list) const
 Return a list of all available resources of the specified type. More...
 
void dumpResourcesList (const Common::UString &fileName) const
 Dump a list of all resources into a file. More...
 

Private Types

enum  Source { kSourceNone, kSourceFile, kSourceArchive }
 Where a resource can be found. More...
 
typedef std::vector< FileTypeFileTypeList
 
typedef std::set< FileTypeFileTypeSet
 
typedef std::list< KnownArchiveKnownArchives
 List of all known archive files. More...
 
typedef std::list< OpenedArchiveOpenedArchives
 List of all opened archive files. More...
 
typedef std::list< ResourceResourceList
 List of resources, sorted by priority. More...
 
typedef std::map< uint64, ResourceListResourceMap
 Map over resources, indexed by their hashed name. More...
 
typedef std::pair< KnownArchives *, KnownArchives::iterator > KnownArchiveChange
 A change produced by adding an archive. More...
 
typedef OpenedArchives::iterator OpenedArchiveChange
 A change produced by indexing/opening an archive. More...
 
typedef std::list< KnownArchiveChangeKnownArchiveChanges
 
typedef std::list< OpenedArchiveChangeOpenedArchiveChanges
 
typedef std::list< ResourceChangeResourceChanges
 
typedef std::list< ChangeSetChangeSetList
 

Private Member Functions

void clearResources ()
 
KnownArchivefindArchive (const Common::UString &file)
 
KnownArchivefindArchive (Common::UString file, KnownArchives &archives)
 
void indexKEY (Common::SeekableReadStream *stream, uint32 priority, Change *change)
 
uint32 openKEYBIFs (Common::SeekableReadStream *keyStream, std::vector< KnownArchive *> &archives, std::vector< KEYDataFile *> &keyData)
 
void indexArchive (KnownArchive &knownArchive, Archive *archive, uint32 priority, Change *change)
 
Common::SeekableReadStreamopenArchiveStream (const KnownArchive &archive) const
 
bool checkResourceIsArchive (Resource &resource, Change *change)
 
void addResource (Resource &resource, uint64 hash, Change *change)
 
void addResource (const Common::UString &path, Change *change, uint32 priority)
 
void addResources (const Common::FileList &files, Change *change, uint32 priority)
 
const ResourcegetRes (uint64 hash) const
 
const ResourcegetRes (const Common::UString &name, const std::vector< FileType > &types) const
 
const ResourcegetRes (const Common::UString &name, FileType type) const
 
Common::SeekableReadStreamgetResource (const Resource &res, bool tryNoCopy=false) const
 
Common::SeekableReadStreamgetArchiveResource (const Resource &res, bool tryNoCopy=false) const
 
uint32 getResourceSize (const Resource &res) const
 
bool normalizeType (Resource &resource)
 
ArchiveType getArchiveType (FileType type) const
 
ArchiveType getArchiveType (const Common::UString &name) const
 
Common::UString getArchiveName (const Resource &resource) const
 
uint64 getHash (const Common::UString &name, FileType type) const
 
uint64 getHash (const Common::UString &name) const
 
void checkHashCollision (const Resource &resource, ResourceMap::const_iterator resList)
 
ChangenewChangeSet (Common::ChangeID &changeID)
 

Private Attributes

bool _hasSmall
 Do we have "small" files? More...
 
Common::HashAlgo _hashAlgo
 With which hash algorithm are/should the names be hashed? More...
 
std::vector< Common::UString_cursorRemap
 Cursor ID -> cursor name. More...
 
Common::UString _baseDir
 The data base directory (if any), the directory the current game is in. More...
 
Common::UString _baseArchive
 The data base archive (if any), the archive the current game is in. More...
 
KnownArchives _knownArchives [kArchiveMAX]
 List of all known archives. More...
 
OpenedArchives _openedArchives
 List of currently used archives. More...
 
std::map< FileType, FileType_typeAliases
 The current type aliases, changing one type to another. More...
 
ResourceMap _resources
 All currently known resources. More...
 
ChangeSetList _changes
 Changes produced by indexing the currently known resources. More...
 
FileTypeSet _archiveTypeTypes [kArchiveMAX]
 All valid archive types file types. More...
 
FileTypeList _resourceTypeTypes [kResourceMAX]
 All valid resource type file types. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Common::Singleton< ResourceManager >
static ResourceManager & instance ()
 
static void destroy ()
 
- Protected Types inherited from Common::Singleton< ResourceManager >
typedef ResourceManager SingletonBaseType
 
- Protected Member Functions inherited from Common::Singleton< ResourceManager >
 Singleton ()
 
virtual ~Singleton ()
 

Detailed Description

A resource manager holding information about and handling all request for all resources usable by the game.

Definition at line 55 of file resman.h.

Member Typedef Documentation

◆ ChangeSetList

Definition at line 452 of file resman.h.

◆ FileTypeList

typedef std::vector<FileType> Aurora::ResourceManager::FileTypeList
private

Definition at line 343 of file resman.h.

◆ FileTypeSet

Definition at line 344 of file resman.h.

◆ KnownArchiveChange

typedef std::pair<KnownArchives *, KnownArchives::iterator> Aurora::ResourceManager::KnownArchiveChange
private

A change produced by adding an archive.

Definition at line 432 of file resman.h.

◆ KnownArchiveChanges

Definition at line 441 of file resman.h.

◆ KnownArchives

List of all known archive files.

Definition at line 382 of file resman.h.

◆ OpenedArchiveChange

typedef OpenedArchives::iterator Aurora::ResourceManager::OpenedArchiveChange
private

A change produced by indexing/opening an archive.

Definition at line 434 of file resman.h.

◆ OpenedArchiveChanges

Definition at line 442 of file resman.h.

◆ OpenedArchives

List of all opened archive files.

Definition at line 384 of file resman.h.

◆ ResourceChanges

Definition at line 443 of file resman.h.

◆ ResourceList

typedef std::list<Resource> Aurora::ResourceManager::ResourceList
private

List of resources, sorted by priority.

Definition at line 425 of file resman.h.

◆ ResourceMap

Map over resources, indexed by their hashed name.

Definition at line 427 of file resman.h.

Member Enumeration Documentation

◆ Source

Where a resource can be found.

Enumerator
kSourceNone 

Invalid source.

kSourceFile 

A direct file.

kSourceArchive 

Within an archive.

Definition at line 389 of file resman.h.

Constructor & Destructor Documentation

◆ ResourceManager()

Aurora::ResourceManager::ResourceManager ( )

◆ ~ResourceManager()

Aurora::ResourceManager::~ResourceManager ( )

Definition at line 173 of file resman.cpp.

References clearResources().

Here is the call graph for this function:

Member Function Documentation

◆ addResource() [1/2]

void Aurora::ResourceManager::addResource ( Resource resource,
uint64  hash,
Change change 
)
private

Definition at line 953 of file resman.cpp.

References Aurora::ResourceManager::Change::_change, _resources, checkHashCollision(), and checkResourceIsArchive().

Referenced by addResource(), addResources(), indexArchive(), and indexResourceFile().

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

◆ addResource() [2/2]

void Aurora::ResourceManager::addResource ( const Common::UString path,
Change change,
uint32  priority 
)
private

◆ addResources()

void Aurora::ResourceManager::addResources ( const Common::FileList files,
Change change,
uint32  priority 
)
private

Definition at line 1011 of file resman.cpp.

References addResource(), Common::FileList::begin(), and Common::FileList::end().

Referenced by indexResourceDir().

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

◆ addTypeAlias()

void Aurora::ResourceManager::addTypeAlias ( FileType  alias,
FileType  realType 
)

Add an alias for one file type to another.

Parameters
aliasThe type to alias.
realTypeThe actual type a resource of the alias type is.

Definition at line 608 of file resman.cpp.

References _typeAliases.

◆ blacklist()

void Aurora::ResourceManager::blacklist ( const Common::UString name,
FileType  type 
)

Blacklist a specific resource.

That resource will never be returned when asked for. The ResourceManager will act like it just doesn't exist. Useful in cases where some resources of different FileTypes in a ResourceType are broken and should not be preferred over the working ones.

Definition at line 612 of file resman.cpp.

References _resources, and getHash().

Here is the call graph for this function:

◆ checkHashCollision()

void Aurora::ResourceManager::checkHashCollision ( const Resource resource,
ResourceMap::const_iterator  resList 
)
private

Definition at line 903 of file resman.cpp.

References Common::UString::c_str(), Common::UString::empty(), Common::formatHash(), getHash(), Aurora::ResourceManager::Resource::name, Aurora::ResourceManager::Resource::type, TypeMan, and warning().

Referenced by addResource().

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

◆ checkResourceIsArchive()

bool Aurora::ResourceManager::checkResourceIsArchive ( Resource resource,
Change change 
)
private

◆ clear()

void Aurora::ResourceManager::clear ( )

Clear all resource information.

Definition at line 177 of file resman.cpp.

References _hashAlgo, _hasSmall, _typeAliases, clearResources(), Common::kHashFNV64, and setRIMsAreERFs().

Referenced by clearResources().

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

◆ clearResources()

void Aurora::ResourceManager::clearResources ( )
private

Definition at line 187 of file resman.cpp.

References _baseArchive, _baseDir, _changes, _cursorRemap, _knownArchives, _openedArchives, _resources, clear(), Common::UString::clear(), and Aurora::kArchiveMAX.

Referenced by clear(), registerDataBase(), and ~ResourceManager().

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

◆ declareResource() [1/2]

void Aurora::ResourceManager::declareResource ( const Common::UString name,
FileType  type 
)

Declare the name of a specific resource.

Useful for declaring the name and type of hashed resources.

Parameters
nameThe name (ResRef) of the resource.
typeThe resource's type.

Definition at line 621 of file resman.cpp.

References _hasSmall, _resources, checkResourceIsArchive(), getHash(), Aurora::kFileTypeSMALL, and TypeMan.

Referenced by declareResource().

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

◆ declareResource() [2/2]

void Aurora::ResourceManager::declareResource ( const Common::UString name)

Declare the name of a specific resource.

Useful for declaring the name and type of hashed resources.

Parameters
nameThe name (with extension) of the resource.

Definition at line 646 of file resman.cpp.

References declareResource(), Aurora::kFileTypeNone, and TypeMan.

Here is the call graph for this function:

◆ dumpResourcesList()

void Aurora::ResourceManager::dumpResourcesList ( const Common::UString fileName) const

◆ findArchive() [1/2]

ResourceManager::KnownArchive * Aurora::ResourceManager::findArchive ( const Common::UString file)
private

Definition at line 267 of file resman.cpp.

References _knownArchives, getArchiveType(), and Aurora::kArchiveMAX.

Referenced by hasArchive(), indexArchive(), and openKEYBIFs().

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

◆ findArchive() [2/2]

ResourceManager::KnownArchive * Aurora::ResourceManager::findArchive ( Common::UString  file,
KnownArchives archives 
)
private

◆ findResourceFile() [1/4]

Common::UString Aurora::ResourceManager::findResourceFile ( const Common::UString name,
FileType  type 
) const

Find and return the absolute filesystem file behind a resource.

If this resources does not exist, or the resource is not a direct file (because it's found within an archive), an empty string will be returned.

Parameters
nameThe name (ResRef) of the resource.
typeThe resource's type.

Definition at line 676 of file resman.cpp.

Referenced by findResourceFile().

Here is the caller graph for this function:

◆ findResourceFile() [2/4]

Common::UString Aurora::ResourceManager::findResourceFile ( const Common::UString name,
ResourceType  type 
) const

Find and return the absolute filesystem file behind a resource.

If this resources does not exist, or the resource is not a direct file (because it's found within an archive), an empty string will be returned.

Parameters
nameThe name (ResRef) of the resource.
typeThe resource's type.

Definition at line 684 of file resman.cpp.

References _resourceTypeTypes, findResourceFile(), and Aurora::kResourceMAX.

Here is the call graph for this function:

◆ findResourceFile() [3/4]

Common::UString Aurora::ResourceManager::findResourceFile ( const Common::UString name) const

Find and return the absolute filesystem file behind a resource.

If this resources does not exist, or the resource is not a direct file (because it's found within an archive), an empty string will be returned.

Parameters
nameThe name (with extension) of the resource.

Definition at line 690 of file resman.cpp.

References findResourceFile(), Aurora::kFileTypeNone, and TypeMan.

Here is the call graph for this function:

◆ findResourceFile() [4/4]

Common::UString Aurora::ResourceManager::findResourceFile ( const Common::UString name,
const std::vector< FileType > &  types 
) const

Find and return the absolute filesystem file behind a resource.

If this resources does not exist, or the resource is not a direct file (because it's found within an archive), an empty string will be returned.

Parameters
nameThe name (ResRef) of the resource.
typesThe resource's types.

Definition at line 694 of file resman.cpp.

References getRes(), kSourceFile, Aurora::ResourceManager::Resource::path, and Aurora::ResourceManager::Resource::source.

Here is the call graph for this function:

◆ getArchiveName()

Common::UString Aurora::ResourceManager::getArchiveName ( const Resource resource) const
private

◆ getArchiveResource()

Common::SeekableReadStream * Aurora::ResourceManager::getArchiveResource ( const Resource res,
bool  tryNoCopy = false 
) const
private

Definition at line 717 of file resman.cpp.

References Aurora::ResourceManager::OpenedArchive::archive, Aurora::ResourceManager::Resource::archive, Aurora::ResourceManager::Resource::archiveIndex, and Aurora::Archive::getResource().

Referenced by getResource().

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

◆ getArchiveType() [1/2]

ArchiveType Aurora::ResourceManager::getArchiveType ( FileType  type) const
private

Definition at line 837 of file resman.cpp.

References _archiveTypeTypes, and Aurora::kArchiveMAX.

Referenced by checkResourceIsArchive(), findArchive(), and getArchiveType().

Here is the caller graph for this function:

◆ getArchiveType() [2/2]

ArchiveType Aurora::ResourceManager::getArchiveType ( const Common::UString name) const
private

Definition at line 845 of file resman.cpp.

References getArchiveType(), and TypeMan.

Here is the call graph for this function:

◆ getAvailableResources() [1/3]

void Aurora::ResourceManager::getAvailableResources ( FileType  type,
std::list< ResourceID > &  list 
) const

Return a list of all available resources of the specified type.

Definition at line 800 of file resman.cpp.

References _resources.

Referenced by getAvailableResources().

Here is the caller graph for this function:

◆ getAvailableResources() [2/3]

void Aurora::ResourceManager::getAvailableResources ( const std::vector< FileType > &  types,
std::list< ResourceID > &  list 
) const

Return a list of all available resources of the specified type.

Definition at line 814 of file resman.cpp.

References _resources.

◆ getAvailableResources() [3/3]

void Aurora::ResourceManager::getAvailableResources ( ResourceType  type,
std::list< ResourceID > &  list 
) const

Return a list of all available resources of the specified type.

Definition at line 831 of file resman.cpp.

References _resourceTypeTypes, and getAvailableResources().

Here is the call graph for this function:

◆ getDataBase()

const Common::UString & Aurora::ResourceManager::getDataBase ( ) const

Return the path of the currently registered base data directory or archive.

Definition at line 260 of file resman.cpp.

References _baseArchive, _baseDir, and Common::UString::empty().

Here is the call graph for this function:

◆ getHash() [1/2]

uint64 Aurora::ResourceManager::getHash ( const Common::UString name,
FileType  type 
) const
inlineprivate

Definition at line 895 of file resman.cpp.

References TypeMan.

Referenced by addResource(), blacklist(), checkHashCollision(), declareResource(), getRes(), and indexArchive().

Here is the caller graph for this function:

◆ getHash() [2/2]

uint64 Aurora::ResourceManager::getHash ( const Common::UString name) const
inlineprivate

Definition at line 899 of file resman.cpp.

References _hashAlgo, Common::hashString(), and Common::UString::toLower().

Here is the call graph for this function:

◆ getRes() [1/3]

const ResourceManager::Resource * Aurora::ResourceManager::getRes ( uint64  hash) const
private

Definition at line 1016 of file resman.cpp.

References _resources.

Referenced by findResourceFile(), getRes(), getResource(), and hasResource().

Here is the caller graph for this function:

◆ getRes() [2/3]

const ResourceManager::Resource * Aurora::ResourceManager::getRes ( const Common::UString name,
const std::vector< FileType > &  types 
) const
private

Definition at line 1024 of file resman.cpp.

References _hasSmall, getHash(), getRes(), Aurora::kFileTypeSMALL, and TypeMan.

Here is the call graph for this function:

◆ getRes() [3/3]

const ResourceManager::Resource * Aurora::ResourceManager::getRes ( const Common::UString name,
FileType  type 
) const
private

Definition at line 1046 of file resman.cpp.

References getRes().

Here is the call graph for this function:

◆ getResource() [1/6]

Common::SeekableReadStream * Aurora::ResourceManager::getResource ( uint64  hash,
FileType type = 0 
) const

Return a resource.

Parameters
hashThe hash of the name and extension of the resource.
typeIf != 0, that's where the type of the resource is stored.
Returns
The resource stream or 0 if the resource doesn't exist.

Definition at line 750 of file resman.cpp.

References getRes(), and Aurora::ResourceManager::Resource::type.

Referenced by getResource(), and openArchiveStream().

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

◆ getResource() [2/6]

Common::SeekableReadStream * Aurora::ResourceManager::getResource ( const Common::UString name,
FileType  type 
) const

Return a resource.

Parameters
nameThe name (ResRef) of the resource.
typeThe resource's type.
Returns
The resource stream or 0 if the resource doesn't exist.

Definition at line 724 of file resman.cpp.

References getResource().

Here is the call graph for this function:

◆ getResource() [3/6]

Common::SeekableReadStream * Aurora::ResourceManager::getResource ( const Common::UString name) const

Return a resource.

Parameters
nameThe name (with extension) of the resource.
Returns
The resource stream or 0 if the resource doesn't exist.

Definition at line 732 of file resman.cpp.

References getResource(), Aurora::kFileTypeNone, and TypeMan.

Here is the call graph for this function:

◆ getResource() [4/6]

Common::SeekableReadStream * Aurora::ResourceManager::getResource ( const Common::UString name,
const std::vector< FileType > &  types,
FileType foundType = 0 
) const

Return a resource.

This only returns one stream, even if more than one of the specified file types exist for the given name.

Parameters
nameThe name (ResRef) of the resource.
typesA list of file types to look for.
foundTypeIf != 0, that's where the actually found type is stored.
Returns
The resource stream or 0 if the resource doesn't exist.

Definition at line 736 of file resman.cpp.

References getRes(), getResource(), and Aurora::ResourceManager::Resource::type.

Here is the call graph for this function:

◆ getResource() [5/6]

Common::SeekableReadStream * Aurora::ResourceManager::getResource ( ResourceType  resType,
const Common::UString name,
FileType foundType = 0 
) const

Return a resource of a specific type.

Parameters
resTypeThe type of the resource.
nameThe name (ResRef or path) of the resource.
foundTypeIf != 0, that's where the actually found type is stored.
Returns
The resource stream or 0 if the music resource doesn't exist.

Definition at line 786 of file resman.cpp.

References _resourceTypeTypes, getResource(), and Aurora::kResourceMAX.

Here is the call graph for this function:

◆ getResource() [6/6]

Common::SeekableReadStream * Aurora::ResourceManager::getResource ( const Resource res,
bool  tryNoCopy = false 
) const
private

◆ getResourceSize()

uint32 Aurora::ResourceManager::getResourceSize ( const Resource res) const
private

◆ hasArchive()

bool Aurora::ResourceManager::hasArchive ( const Common::UString file)

Does a specific archive exist?

Parameters
fileThe name of the archive file.
Returns
true if the archive exists, false otherwise.

Definition at line 292 of file resman.cpp.

References findArchive().

Here is the call graph for this function:

◆ hasResource() [1/5]

bool Aurora::ResourceManager::hasResource ( uint64  hash) const

Does a specific resource exist?

Parameters
hashThe hash of the name and extension of the resource.
Returns
true if the resource exists, false otherwise.

Definition at line 672 of file resman.cpp.

References getRes().

Referenced by hasResource().

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

◆ hasResource() [2/5]

bool Aurora::ResourceManager::hasResource ( const Common::UString name,
FileType  type 
) const

Does a specific resource exist?

Parameters
nameThe name (ResRef) of the resource.
typeThe resource's type.
Returns
true if the resource exists, false otherwise.

Definition at line 650 of file resman.cpp.

References hasResource().

Here is the call graph for this function:

◆ hasResource() [3/5]

bool Aurora::ResourceManager::hasResource ( const Common::UString name,
ResourceType  type 
) const

Does a specific resource exist?

Parameters
nameThe name (ResRef) of the resource.
typeThe resource's type.
Returns
true if the resource exists, false otherwise.

Definition at line 658 of file resman.cpp.

References _resourceTypeTypes, hasResource(), and Aurora::kResourceMAX.

Here is the call graph for this function:

◆ hasResource() [4/5]

bool Aurora::ResourceManager::hasResource ( const Common::UString name) const

Does a specific resource exist?

Parameters
nameThe name (with extension) of the resource.
Returns
true if the resource exists, false otherwise.

Definition at line 664 of file resman.cpp.

References hasResource(), Aurora::kFileTypeNone, and TypeMan.

Here is the call graph for this function:

◆ hasResource() [5/5]

bool Aurora::ResourceManager::hasResource ( const Common::UString name,
const std::vector< FileType > &  types 
) const

Does a specific resource exist?

Parameters
nameThe name (ResRef) of the resource.
typesThe resource's types.
Returns
true if the resource exists, false otherwise.

Definition at line 668 of file resman.cpp.

References getRes().

Here is the call graph for this function:

◆ hasResourceDir()

bool Aurora::ResourceManager::hasResourceDir ( const Common::UString dir)

Does a specific directory, relative to the base directory, exist?

Parameters
dirA subdirectory of the base directory to look for.
Returns
true if the directory exists, false otherwise.

Definition at line 473 of file resman.cpp.

References _baseDir, Common::UString::empty(), and Common::FilePath::findSubDirectory().

Here is the call graph for this function:

◆ indexArchive() [1/3]

void Aurora::ResourceManager::indexArchive ( const Common::UString file,
uint32  priority,
Common::ChangeID changeID = 0 
)

Add all the resources of an archive to the resource manager.

Parameters
fileThe name of the archive file to index.
priorityThe priority these files have over others of the same name and type. Higher number = higher priority. 0 means blacklisted.
changeIDIf given, record the collective changes done here.

Definition at line 361 of file resman.cpp.

Referenced by indexArchive(), indexKEY(), and registerDataBase().

Here is the caller graph for this function:

◆ indexArchive() [2/3]

void Aurora::ResourceManager::indexArchive ( const Common::UString file,
uint32  priority,
const std::vector< byte > &  password,
Common::ChangeID changeID = 0 
)

Add all the resources of an archive to the resource manager.

Parameters
fileThe name of the archive file to index.
priorityThe priority these files have over others of the same name and type. Higher number = higher priority. 0 means blacklisted.
passwordUse this password to decrypt the archive file, if necessary.
changeIDIf given, record the collective changes done here.

Definition at line 303 of file resman.cpp.

References _cursorRemap, Common::UString::c_str(), findArchive(), indexArchive(), indexKEY(), Aurora::kArchiveBIF, Aurora::kArchiveERF, Aurora::kArchiveEXE, Aurora::kArchiveHERF, Aurora::kArchiveKEY, Aurora::kArchiveNDS, Aurora::kArchiveNSBTX, Aurora::kArchiveRIM, Aurora::kArchiveZIP, newChangeSet(), openArchiveStream(), Common::ScopedPtrBase< T, Deallocator >::release(), Common::ScopedPtrBase< T, Deallocator >::reset(), and Aurora::ResourceManager::KnownArchive::type.

Here is the call graph for this function:

◆ indexArchive() [3/3]

void Aurora::ResourceManager::indexArchive ( KnownArchive knownArchive,
Archive archive,
uint32  priority,
Change change 
)
private

◆ indexKEY()

void Aurora::ResourceManager::indexKEY ( Common::SeekableReadStream stream,
uint32  priority,
Change change 
)
private

Definition at line 406 of file resman.cpp.

References indexArchive(), and openKEYBIFs().

Referenced by indexArchive().

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

◆ indexResourceDir()

void Aurora::ResourceManager::indexResourceDir ( const Common::UString dir,
const char *  glob,
int  depth,
uint32  priority,
Common::ChangeID changeID = 0 
)

Add a directory's contents to the resource manager.

Relative to the base directory.

Parameters
dirA subdirectory of the base directory to search for resource files.
globA pattern of which files to look for.
depthThe number of levels to recurse into subdirectories. 0 for ignoring subdirectories, -1 for a limitless recursion.
priorityThe priority these files have over others of the same name and type. Higher number = higher priority. 0 means blacklisted.
changeIDIf given, record the collective changes done here.

Definition at line 497 of file resman.cpp.

References _baseDir, Common::FileList::addDirectory(), addResources(), Common::UString::c_str(), Common::UString::empty(), Common::FilePath::findSubDirectory(), Common::FileList::getSubListGlob(), and newChangeSet().

Referenced by registerDataBase().

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

◆ indexResourceFile()

void Aurora::ResourceManager::indexResourceFile ( const Common::UString file,
uint32  priority,
Common::ChangeID changeID = 0 
)

Add a single file to the resource manager.

Relative to the base directory.

Parameters
fileThe file to add.
priorityThe priority these files have over others of the same name and type. Higher number = higher priority. 0 means blacklisted.
changeIDIf given, record the collective changes done here.

Definition at line 480 of file resman.cpp.

References _baseDir, addResource(), Common::UString::c_str(), Common::UString::empty(), Common::FilePath::isRegularFile(), newChangeSet(), and Common::FilePath::normalize().

Referenced by registerDataBase().

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

◆ newChangeSet()

ResourceManager::Change * Aurora::ResourceManager::newChangeSet ( Common::ChangeID changeID)
private

Definition at line 1083 of file resman.cpp.

References Aurora::ResourceManager::Change::_change, _changes, Common::ChangeID::getContent(), and Common::ChangeID::setContent().

Referenced by indexArchive(), indexResourceDir(), and indexResourceFile().

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

◆ normalizeType()

bool Aurora::ResourceManager::normalizeType ( Resource resource)
private

◆ openArchiveStream()

Common::SeekableReadStream * Aurora::ResourceManager::openArchiveStream ( const KnownArchive archive) const
private

Definition at line 296 of file resman.cpp.

References getResource(), and Aurora::ResourceManager::KnownArchive::resource.

Referenced by indexArchive(), and openKEYBIFs().

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

◆ openKEYBIFs()

uint32 Aurora::ResourceManager::openKEYBIFs ( Common::SeekableReadStream keyStream,
std::vector< KnownArchive *> &  archives,
std::vector< KEYDataFile *> &  keyData 
)
private

Definition at line 367 of file resman.cpp.

References _knownArchives, findArchive(), Aurora::KEYFile::getBIFs(), Common::FilePath::getExtension(), Aurora::kArchiveBIF, and openArchiveStream().

Referenced by indexKEY().

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

◆ registerDataBase()

void Aurora::ResourceManager::registerDataBase ( const Common::UString path)

Register a path to be the data base.

If this is a directory, it will be indexed, non-recursively. If this is a file, it will be indexed as an archive.

The priority of files within the data base is always 1, the lowest priority.

All further games files and archives are assumed to be inside this directory or archive.

Parameters
pathThe path to a base data directory or archive.

Definition at line 237 of file resman.cpp.

References _baseArchive, _baseDir, Common::UString::c_str(), Common::FilePath::canonicalize(), clearResources(), indexArchive(), indexResourceDir(), indexResourceFile(), Common::FilePath::isDirectory(), and Common::FilePath::isRegularFile().

Here is the call graph for this function:

◆ setCursorRemap()

void Aurora::ResourceManager::setCursorRemap ( const std::vector< Common::UString > &  remap)

Set the array used to map cursor ID to cursor names.

Definition at line 233 of file resman.cpp.

References _cursorRemap.

◆ setHashAlgo()

void Aurora::ResourceManager::setHashAlgo ( Common::HashAlgo  algo)

With which hash algorithm are/should the names be hashed?

Definition at line 226 of file resman.cpp.

References _hashAlgo, and _resources.

◆ setHasSmall()

void Aurora::ResourceManager::setHasSmall ( bool  hasSmall)

Do we have "small" files (compressed with Nintendo DS's LZSS algorithm)?

Definition at line 222 of file resman.cpp.

References _hasSmall.

◆ setRIMsAreERFs()

void Aurora::ResourceManager::setRIMsAreERFs ( bool  rimsAreERFs)

Are .rim/.rimp files actually ERF files?

Definition at line 205 of file resman.cpp.

References _archiveTypeTypes, Aurora::kArchiveERF, Aurora::kArchiveRIM, Aurora::kFileTypeRIM, and Aurora::kFileTypeRIMP.

Referenced by clear().

Here is the caller graph for this function:

◆ undo()

void Aurora::ResourceManager::undo ( Common::ChangeID changeID)

Undo the changes done in the specified change ID.

Definition at line 529 of file resman.cpp.

References Aurora::ResourceManager::Change::_change, _changes, _openedArchives, _resources, Common::ChangeID::clear(), and Common::ChangeID::getContent().

Here is the call graph for this function:

Member Data Documentation

◆ _archiveTypeTypes

FileTypeSet Aurora::ResourceManager::_archiveTypeTypes[kArchiveMAX]
private

All valid archive types file types.

Definition at line 493 of file resman.h.

Referenced by getArchiveType(), ResourceManager(), and setRIMsAreERFs().

◆ _baseArchive

Common::UString Aurora::ResourceManager::_baseArchive
private

The data base archive (if any), the archive the current game is in.

Definition at line 482 of file resman.h.

Referenced by clearResources(), getDataBase(), and registerDataBase().

◆ _baseDir

Common::UString Aurora::ResourceManager::_baseDir
private

The data base directory (if any), the directory the current game is in.

Definition at line 480 of file resman.h.

Referenced by clearResources(), getDataBase(), hasResourceDir(), indexResourceDir(), indexResourceFile(), and registerDataBase().

◆ _changes

ChangeSetList Aurora::ResourceManager::_changes
private

Changes produced by indexing the currently known resources.

Definition at line 491 of file resman.h.

Referenced by clearResources(), newChangeSet(), and undo().

◆ _cursorRemap

std::vector<Common::UString> Aurora::ResourceManager::_cursorRemap
private

Cursor ID -> cursor name.

Definition at line 477 of file resman.h.

Referenced by clearResources(), indexArchive(), and setCursorRemap().

◆ _hashAlgo

Common::HashAlgo Aurora::ResourceManager::_hashAlgo
private

With which hash algorithm are/should the names be hashed?

Definition at line 474 of file resman.h.

Referenced by clear(), getHash(), indexArchive(), and setHashAlgo().

◆ _hasSmall

bool Aurora::ResourceManager::_hasSmall
private

Do we have "small" files?

Definition at line 471 of file resman.h.

Referenced by addResource(), clear(), declareResource(), getRes(), indexArchive(), and setHasSmall().

◆ _knownArchives

KnownArchives Aurora::ResourceManager::_knownArchives[kArchiveMAX]
private

List of all known archives.

Definition at line 484 of file resman.h.

Referenced by checkResourceIsArchive(), clearResources(), findArchive(), and openKEYBIFs().

◆ _openedArchives

OpenedArchives Aurora::ResourceManager::_openedArchives
private

List of currently used archives.

Definition at line 485 of file resman.h.

Referenced by clearResources(), indexArchive(), and undo().

◆ _resources

ResourceMap Aurora::ResourceManager::_resources
private

All currently known resources.

Definition at line 490 of file resman.h.

Referenced by addResource(), blacklist(), clearResources(), declareResource(), dumpResourcesList(), getAvailableResources(), getRes(), setHashAlgo(), and undo().

◆ _resourceTypeTypes

FileTypeList Aurora::ResourceManager::_resourceTypeTypes[kResourceMAX]
private

All valid resource type file types.

Definition at line 494 of file resman.h.

Referenced by findResourceFile(), getAvailableResources(), getResource(), hasResource(), and ResourceManager().

◆ _typeAliases

std::map<FileType, FileType> Aurora::ResourceManager::_typeAliases
private

The current type aliases, changing one type to another.

Definition at line 488 of file resman.h.

Referenced by addTypeAlias(), clear(), and normalizeType().


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