From c6b4edf8cc635ddcb2a8b3c0cef38dd88fa73768 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Thu, 16 Apr 2009 21:22:46 +0200 Subject: Renamed ResourceManager::moveFile to ResourceManager::copyFile and catched error when it fails. --- src/resources/resourcemanager.cpp | 2 +- src/resources/resourcemanager.h | 2 +- src/sound.cpp | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index e24ebafb..f7a2586e 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -419,7 +419,7 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize) return buffer; } -bool ResourceManager::moveFile(const std::string &src, const std::string &dst) +bool ResourceManager::copyFile(const std::string &src, const std::string &dst) { PHYSFS_file *srcFile = PHYSFS_openRead(src.c_str()); if (!srcFile) diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 19c0cb61..b2ad3069 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -133,7 +133,7 @@ class ResourceManager * @return true on success, false on failure. An error message should be * in the log file. */ - bool moveFile(const std::string &src, const std::string &dst); + bool copyFile(const std::string &src, const std::string &dst); /** * Convenience wrapper around ResourceManager::get for loading diff --git a/src/sound.cpp b/src/sound.cpp index 39651045..e2663fa8 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -149,8 +149,13 @@ static Mix_Music *loadMusic(const std::string &filename) // it to a temporary physical file so that SDL_mixer can stream it. logger->log("Loading music \"%s\" from temporary file tempMusic.ogg", path.c_str()); - resman->moveFile("music/" + filename, "tempMusic.ogg"); - path = resman->getPath("tempMusic.ogg"); + bool success = resman->copyFile("music/" + filename, "tempMusic.ogg"); + if (success) + { + path = resman->getPath("tempMusic.ogg"); + } else { + return NULL; + } } else { logger->log("Loading music \"%s\"", path.c_str()); } -- cgit v1.2.3-70-g09d2