summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-01-13 16:28:50 +0000
committerDavid Athay <ko2fan@gmail.com>2008-01-13 16:28:50 +0000
commit3bf3c05f1b999914875d5fb0797c4c9ca098ede0 (patch)
tree8bb49e7960cd27e0343c65ae43d646e52f566f71 /src/resources
parent2928c5444892538f0153b5dd6e39d9a4bff5585d (diff)
downloadmana-client-3bf3c05f1b999914875d5fb0797c4c9ca098ede0.tar.gz
mana-client-3bf3c05f1b999914875d5fb0797c4c9ca098ede0.tar.bz2
mana-client-3bf3c05f1b999914875d5fb0797c4c9ca098ede0.tar.xz
mana-client-3bf3c05f1b999914875d5fb0797c4c9ca098ede0.zip
Fixed non-default location music loading
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/resourcemanager.cpp21
-rw-r--r--src/resources/resourcemanager.h8
2 files changed, 29 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index fb9da9d7..59202ad8 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -200,6 +200,27 @@ ResourceManager::isDirectory(const std::string &path)
return PHYSFS_isDirectory(path.c_str());
}
+std::string
+ResourceManager::getPath(const std::string &file)
+{
+ // get the real path to the file
+ const char* tmp = PHYSFS_getRealDir(file.c_str());
+ std::string path;
+
+ // if the file is not in the search path, then its NULL
+ if (tmp)
+ {
+ path = std::string(tmp) + "/" + file;
+ }
+ else
+ {
+ // if not found in search path return the default path
+ path = std::string(TMW_DATADIR) + std::string("data") + "/" + file;
+ }
+
+ return path;
+}
+
Resource *ResourceManager::get(std::string const &idPath, generator fun, void *data)
{
// Check if the id exists, and return the value if it does.
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index abfd629a..da85e2f9 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -104,6 +104,14 @@ class ResourceManager
*/
bool
isDirectory(const std::string &path);
+
+ /**
+ * Returns the real path to a file
+ *
+ * @param file The file to get the real path to.
+ * @return The real path.
+ */
+ std::string getPath(const std::string &file);
/**
* Creates a resource and adds it to the resource map.