diff options
author | Johannes Schickel | 2007-03-20 20:46:19 +0000 |
---|---|---|
committer | Johannes Schickel | 2007-03-20 20:46:19 +0000 |
commit | b17ae7017cb122fd7e30f54ac4d498bd127b5946 (patch) | |
tree | fb65a8c3f319d15886bc51a07bffc137f12a395e /engines | |
parent | d881196681fff4a4c0024eb6ab38e11b3022603d (diff) | |
download | scummvm-rg350-b17ae7017cb122fd7e30f54ac4d498bd127b5946.tar.gz scummvm-rg350-b17ae7017cb122fd7e30f54ac4d498bd127b5946.tar.bz2 scummvm-rg350-b17ae7017cb122fd7e30f54ac4d498bd127b5946.zip |
Little cleanup.
svn-id: r26263
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/resource.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index b896220d17..9b3ccebb25 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -180,53 +180,45 @@ bool Resource::isInPakList(const Common::String &filename) { } uint8 *Resource::fileData(const char *file, uint32 *size) { - uint8 *buffer = 0; - Common::File file_; + Common::File fileHandle; if (size) *size = 0; // test to open it in the main dir - if (file_.open(file)) { - - uint32 temp = file_.size(); - buffer = new uint8[temp]; + if (fileHandle.open(file)) { + uint32 fileSize = fileHandle.size(); + uint8 *buffer = new uint8[fileSize]; assert(buffer); - file_.read(buffer, temp); + fileHandle.read(buffer, fileSize); if (size) - *size = temp; + *size = fileSize; - file_.close(); + return buffer; } else { // opens the file in a PAK File Common::List<ResourceFile*>::iterator start = _pakfiles.begin(); uint fileHash = Common::hashit_lower(file); - uint32 temp = 0; for (;start != _pakfiles.end(); ++start) { if (!(*start)->isOpen()) continue; - temp = (*start)->getFileSize(fileHash); + uint32 fileSize = (*start)->getFileSize(fileHash); - if (!temp) + if (!fileSize) continue; if (size) - *size = temp; + *size = fileSize; - buffer = (*start)->getFile(fileHash); - break; + return (*start)->getFile(fileHash); } } - if (!buffer) { - return 0; - } - - return buffer; + return 0; } bool Resource::getFileHandle(const char *file, uint32 *size, Common::File &filehandle) { |