Torque2D Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | List of all members
ResManager Class Reference

`#include <resourceManager.h>`

## Public Member Functions
RESOURCE_CREATE_FN | getCreateFunction (const char *name)
| ~ResManager ()
void | setFileNameEcho (bool on)
| Sets whether or not to echo filenames that have been accessed by means of openStream. More...
void | setModPaths (U32 numPaths, const char **dirs)
| Sets the path for the current game mod. More...
const char * | getModPaths ()
| Gets the path for the current game mod. More...
void | addPath (const char *path, bool ignoreZips=false)
| Add a path. More...
void | removePath (const char *path)
| Remove a path. Only removes resources that are not loaded. More...
void | setMissingFileLogging (bool log)
| Should we log missing files? More...
bool | getMissingFileList (Vector< char * > &list)
| Gets which files are missing. More...
void | clearMissingFileList ()
| Clears the missing file list. More...
void | registerExtension (const char *extension, RESOURCE_CREATE_FN create_fn)
| Tells the resource manager what to do with a resource that it loads. More...
S32 | getSize (const char *filename)
| Gets the size of the file. More...
const char * | getFullPath (const char *filename, char *path, U32 pathLen)
| Gets the full path of the file. More...
const char * | getModPathOf (const char *fileName)
| Gets the path of the file local to the mod. More...
const char * | getPathOf (const char *filename)
| Gets the path of the file from the base directory. More...
const char * | getBasePath ()
| Gets the base path. More...
ResourceObject * | load (const char *fileName, bool computeCRC=false)
| loads an instance of an object More...
Stream * | openStream (const char *fileName)
| Opens a stream for an object. More...
Stream * | openStream (ResourceObject *object)
| Opens a stream for an object. More...
void | closeStream (Stream *stream)
| Closes the stream. More...
void | unlock (ResourceObject *)
bool | add (const char *name, ResourceInstance *addInstance, bool extraLock=false)
| Add a new resource instance. More...
ResourceObject * | find (const char *fileName)
| Searches the hash list for the filename and returns it's object if found, otherwise NULL. More...
ResourceInstance * | loadInstance (const char *fileName, bool computeCRC=false)
| Loads a new instance of an object by means of a filename. More...
ResourceInstance * | loadInstance (ResourceObject *object, bool computeCRC=false)
| Loads a new instance of an object by means of a resource object. More...
ResourceObject * | find (const char *fileName, U32 flags)
| Searches the hash list for the filename and returns it's object if found, otherwise NULL. More...
ResourceObject * | findMatch (const char *expression, const char **fn, ResourceObject *start=NULL)
| Finds a resource object with given expression. More...
ResourceObject * | findMatchMultiExprs (const char *multiExpression, const char **fn, ResourceObject *start=NULL)
| Finds a resource object with given expressions, seperated by " ". More...
void | purge ()
| Goes through the timeoutList and deletes it all. BURN!!! More...
void | purge (ResourceObject *obj)
| Deletes one resource object. More...
void | freeResource (ResourceObject *resObject)
| Frees a resource! More...
void | serialize (VectorPtr< const char * > &filenames)
| Sorts the resource objects. More...
S32 | findMatches (FindMatch *pFM)
| Finds multiple matches to an expression. More...
bool | findFile (const char *name)
| Checks to see if a file exists. More...
bool | addVFSRoot (Zip::ZipArchive *vfs)
bool | isUsingVFS ()
bool | getCrc (const char *fileName, U32 &crcVal, const U32 crcInitialVal=INITIAL_CRC_VALUE)
void | setWriteablePath (const char *path)
| Sets the writable path for a file to the one given. More...
bool | isValidWriteFileName (const char *fn)
| Checks to see if the given path is valid for writing. More...
bool | openFileForWrite (FileStream &fs, const char *fileName, U32 accessMode=File::Write)
| Opens a file for writing! More...
void | dumpResources (const bool onlyLoaded=true)
| Dumps all loaded resources to the console. More...

## Global Control
These are called to initialize/destroy the resource manager at runtime.
static void | create ()
static void | destroy ()
static void | initExcludedDirectories ()

## Detailed Description

A virtual file system for the storage and retrieval of ResourceObjects.

Basic resource manager behavior:

- Set the mod path.
  - ResManager scans directory tree under listed base directories
  - Any volume (.zip) file in the root directory of a mod is scanned for resources.
  - Any files currently in the resource manager become memory resources.
  - They can be "reattached" to the first file that matches the file name.

All classes which wish to be handled by the resource manager need:

1. To be derived from ResourceInstance.
2. To register a creation function and file extension with the manager.

## Constructor & Destructor Documentation

~ResManager | ( |  | ) |

## Member Function Documentation

bool add | ( | const char * | name,
|  | ResourceInstance * | addInstance,
|  | bool | extraLock = `false`
| ) |  |

Add a new resource instance.

void addPath | ( | const char * | path,
|  | bool | ignoreZips = `false`
| ) |  |

Add a path.

bool addVFSRoot | ( | Zip::ZipArchive * | vfs | ) |

void clearMissingFileList | ( |  | ) |

Clears the missing file list.

void closeStream | ( | Stream * | stream | ) |

Closes the stream.

void create | ( | void |  | ) |
| static

void destroy | ( |  | ) |
| static

void dumpResources | ( | const bool | onlyLoaded = `true` | ) |

Dumps all loaded resources to the console.

ResourceObject * find | ( | const char * | fileName | ) |

Searches the hash list for the filename and returns it's object if found, otherwise NULL.

ResourceObject * find | ( | const char * | fileName,
|  | U32 | flags
| ) |  |

Searches the hash list for the filename and returns it's object if found, otherwise NULL.

bool findFile | ( | const char * | name | ) |

Checks to see if a file exists.

ResourceObject * findMatch | ( | const char * | expression,
|  | const char ** | fn,
|  | ResourceObject * | start = `NULL`
| ) |  |

Finds a resource object with given expression.

S32 findMatches | ( | FindMatch * | pFM | ) |

Finds multiple matches to an expression.

ResourceObject * findMatchMultiExprs | ( | const char * | multiExpression,
|  | const char ** | fn,
|  | ResourceObject * | start = `NULL`
| ) |  |

Finds a resource object with given expressions, seperated by " ".

void freeResource | ( | ResourceObject * | resObject | ) |

Frees a resource!

const char * getBasePath | ( |  | ) |

Gets the base path.

bool getCrc | ( | const char * | fileName,
|  | U32 & | crcVal,
|  | const U32 | crcInitialVal = `INITIAL_CRC_VALUE`
| ) |  |

Computes the CRC of a file.

By passing a different crcInitialVal, you can take the CRC of multiple files.

RESOURCE_CREATE_FN getCreateFunction | ( | const char * | name | ) |

const char * getFullPath | ( | const char * | filename,
|  | char * | path,
|  | U32 | pathLen
| ) |  |

Gets the full path of the file.

bool getMissingFileList | ( | Vector< char * > & | list | ) |

Gets which files are missing.

const char * getModPathOf | ( | const char * | fileName | ) |

Gets the path of the file local to the mod.

const char * getModPaths | ( |  | ) |

Gets the path for the current game mod.

const char * getPathOf | ( | const char * | filename | ) |

Gets the path of the file from the base directory.

S32 getSize | ( | const char * | filename | ) |

Gets the size of the file.

void initExcludedDirectories | ( |  | ) |
| static

Load the excluded directories from the resource manager pref and stuff it into the platform layer.

bool isUsingVFS | ( |  | ) |
| inline

bool isValidWriteFileName | ( | const char * | fn | ) |

Checks to see if the given path is valid for writing.

ResourceObject * load | ( | const char * | fileName,
|  | bool | computeCRC = `false`
| ) |  |

loads an instance of an object

ResourceInstance * loadInstance | ( | const char * | fileName,
|  | bool | computeCRC = `false`
| ) |  |

Loads a new instance of an object by means of a filename.

ResourceInstance * loadInstance | ( | ResourceObject * | object,
|  | bool | computeCRC = `false`
| ) |  |

Loads a new instance of an object by means of a resource object.

bool openFileForWrite | ( | FileStream & | fs,
|  | const char * | fileName,
|  | U32 | accessMode = `File::Write`
| ) |  |

Opens a file for writing!

Stream * openStream | ( | const char * | fileName | ) |

Opens a stream for an object.

Stream * openStream | ( | ResourceObject * | object | ) |

Opens a stream for an object.

void purge | ( |  | ) |

Goes through the timeoutList and deletes it all. BURN!!!

void purge | ( | ResourceObject * | obj | ) |

Deletes one resource object.

void registerExtension | ( | const char * | extension,
|  | RESOURCE_CREATE_FN | create_fn
| ) |  |

Tells the resource manager what to do with a resource that it loads.

void removePath | ( | const char * | path | ) |

Remove a path. Only removes resources that are not loaded.

void serialize | ( | VectorPtr< const char * > & | filenames | ) |

Sorts the resource objects.

void setFileNameEcho | ( | bool | on | ) |

Sets whether or not to echo filenames that have been accessed by means of openStream.

void setMissingFileLogging | ( | bool | log | ) |

Should we log missing files?

void setModPaths | ( | U32 | numPaths,
|  | const char ** | dirs
| ) |  |

Sets the path for the current game mod.

void setWriteablePath | ( | const char * | path | ) |

Sets the writable path for a file to the one given.

void unlock | ( | ResourceObject * | obj | ) |

Decrements the lock count of an object. If the lock count is zero post-decrement, the object is added to the timeoutList for deletion upon call of flush.

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

- io/resource/resourceManager.h
- io/resource/resourceManager.cc