summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-04-16 20:55:59 +0200
committerPhilipp Sehmisch <crush@themanaworld.org>2009-04-16 21:14:40 +0200
commitdac1c9d9b9558053ab9fc96eac8772604b8eedf2 (patch)
tree7077f0300e6ae39d7de27aae29eb0c4bb06069b5 /src/resources/resourcemanager.cpp
parent255c491375005abb1d2de22fa5aa1a821ac3a4f6 (diff)
downloadmana-client-dac1c9d9b9558053ab9fc96eac8772604b8eedf2.tar.gz
mana-client-dac1c9d9b9558053ab9fc96eac8772604b8eedf2.tar.bz2
mana-client-dac1c9d9b9558053ab9fc96eac8772604b8eedf2.tar.xz
mana-client-dac1c9d9b9558053ab9fc96eac8772604b8eedf2.zip
Added support for playing music in zip files.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r--src/resources/resourcemanager.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 33d5e3e5..e24ebafb 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -419,6 +419,32 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
return buffer;
}
+bool ResourceManager::moveFile(const std::string &src, const std::string &dst)
+{
+ PHYSFS_file *srcFile = PHYSFS_openRead(src.c_str());
+ if (!srcFile)
+ {
+ logger->log("Read error: %s", PHYSFS_getLastError());
+ return false;
+ }
+ PHYSFS_file *dstFile = PHYSFS_openWrite(dst.c_str());
+ if (!dstFile)
+ {
+ logger->log("Write error: %s", PHYSFS_getLastError());
+ PHYSFS_close(srcFile);
+ return false;
+ }
+
+ int fileSize = PHYSFS_fileLength(srcFile);
+ void *buf = malloc(fileSize);
+ PHYSFS_read(srcFile, buf, 1, fileSize);
+ PHYSFS_write(dstFile, buf, 1, fileSize);
+
+ PHYSFS_close(srcFile);
+ PHYSFS_close(dstFile);
+ return true;
+}
+
std::vector<std::string> ResourceManager::loadTextFile(const std::string &fileName)
{
int contentsLength;