SCUMM: Replace Common::File uses by SeekableReadStream and SearchMan

svn-id: r54434
This commit is contained in:
Max Horn 2010-11-23 22:25:10 +00:00
parent 55e3ed0016
commit 54e0390752
9 changed files with 15 additions and 31 deletions

View file

@ -466,7 +466,7 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
// //
DetectorDesc &d = fileMD5Map[file]; DetectorDesc &d = fileMD5Map[file];
if (d.md5.empty()) { if (d.md5.empty()) {
Common::File *tmp = 0; Common::SeekableReadStream *tmp = 0;
bool isDiskImg = (file.hasSuffix(".d64") || file.hasSuffix(".dsk") || file.hasSuffix(".prg")); bool isDiskImg = (file.hasSuffix(".d64") || file.hasSuffix(".dsk") || file.hasSuffix(".prg"));
if (isDiskImg) { if (isDiskImg) {
@ -474,12 +474,11 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
debug(2, "Falling back to disk-based detection"); debug(2, "Falling back to disk-based detection");
} else { } else {
tmp = new Common::File; tmp = d.node.createReadStream();
tmp->open(d.node);
} }
Common::String md5str; Common::String md5str;
if (tmp && tmp->isOpen()) if (tmp)
md5str = computeStreamMD5AsString(*tmp, kMD5FileSizeLimit); md5str = computeStreamMD5AsString(*tmp, kMD5FileSizeLimit);
if (!md5str.empty()) { if (!md5str.empty()) {

View file

@ -26,8 +26,6 @@
#if !defined(SCUMM_HE_ANIMATION_H) && defined(ENABLE_HE) #if !defined(SCUMM_HE_ANIMATION_H) && defined(ENABLE_HE)
#define SCUMM_HE_ANIMATION_H #define SCUMM_HE_ANIMATION_H
#include "common/file.h"
#include "graphics/video/smk_decoder.h" #include "graphics/video/smk_decoder.h"
#include "sound/mixer.h" #include "sound/mixer.h"

View file

@ -1412,12 +1412,7 @@ void ScummEngine_v72he::o72_openFile() {
if (!_saveFileMan->listSavefiles(filename).empty()) { if (!_saveFileMan->listSavefiles(filename).empty()) {
_hInFileTable[slot] = _saveFileMan->openForLoading(filename); _hInFileTable[slot] = _saveFileMan->openForLoading(filename);
} else { } else {
Common::File *f = new Common::File(); _hInFileTable[slot] = SearchMan.createReadStreamForMember(filename);
f->open(filename);
if (!f->isOpen())
delete f;
else
_hInFileTable[slot] = f;
} }
break; break;
case 2: case 2:

View file

@ -25,6 +25,7 @@
#ifdef ENABLE_HE #ifdef ENABLE_HE
#include "common/archive.h"
#include "common/config-file.h" #include "common/config-file.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/savefile.h" #include "common/savefile.h"
@ -94,14 +95,9 @@ void ScummEngine_v80he::o80_getFileSize() {
Common::SeekableReadStream *f = 0; Common::SeekableReadStream *f = 0;
if (!_saveFileMan->listSavefiles(filename).empty()) { if (!_saveFileMan->listSavefiles(filename).empty()) {
f = _saveFileMan->openForLoading((const char *)filename); f = _saveFileMan->openForLoading(filename);
} else { } else {
Common::File *file = new Common::File(); f = SearchMan.createReadStreamForMember(filename);
file->open((const char *)filename);
if (!file->isOpen())
delete file;
else
f = file;
} }
if (!f) { if (!f) {

View file

@ -25,6 +25,7 @@
#ifdef ENABLE_HE #ifdef ENABLE_HE
#include "common/archive.h"
#include "common/system.h" #include "common/system.h"
#include "graphics/cursorman.h" #include "graphics/cursorman.h"
#include "graphics/primitives.h" #include "graphics/primitives.h"
@ -2374,12 +2375,7 @@ void Wiz::processWizImage(const WizParameters *params) {
if (!_vm->_saveFileMan->listSavefiles(filename).empty()) { if (!_vm->_saveFileMan->listSavefiles(filename).empty()) {
f = _vm->_saveFileMan->openForLoading(filename); f = _vm->_saveFileMan->openForLoading(filename);
} else { } else {
Common::File *nf = new Common::File(); f = SearchMan.createReadStreamForMember(filename);
nf->open(filename);
if (!nf->isOpen())
delete nf;
else
f = nf;
} }
if (f) { if (f) {

View file

@ -157,7 +157,7 @@ BundleMgr::~BundleMgr() {
delete _file; delete _file;
} }
Common::File *BundleMgr::getFile(const char *filename, int32 &offset, int32 &size) { Common::SeekableReadStream *BundleMgr::getFile(const char *filename, int32 &offset, int32 &size) {
BundleDirCache::IndexNode target; BundleDirCache::IndexNode target;
strcpy(target.filename, filename); strcpy(target.filename, filename);
BundleDirCache::IndexNode *found = (BundleDirCache::IndexNode *)bsearch(&target, _indexTable, _numFiles, BundleDirCache::IndexNode *found = (BundleDirCache::IndexNode *)bsearch(&target, _indexTable, _numFiles,

View file

@ -101,7 +101,7 @@ public:
bool open(const char *filename, bool &compressed, bool errorFlag = false); bool open(const char *filename, bool &compressed, bool errorFlag = false);
void close(); void close();
Common::File *getFile(const char *filename, int32 &offset, int32 &size); Common::SeekableReadStream *getFile(const char *filename, int32 &offset, int32 &size);
int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **compFinal, bool headerOutside); int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **compFinal, bool headerOutside);
int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **compFinal, int header_size, bool headerOutside); int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **compFinal, int header_size, bool headerOutside);
int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside); int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside);

View file

@ -93,7 +93,7 @@ void ImuseDigiSndMgr::countElements(byte *ptr, int &numRegions, int &numJumps, i
} while (tag != MKID_BE('DATA')); } while (tag != MKID_BE('DATA'));
} }
void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, SoundDesc *sound, int32 offset, int32 size) { void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::SeekableReadStream *file, SoundDesc *sound, int32 offset, int32 size) {
int l; int l;
file->seek(offset, SEEK_SET); file->seek(offset, SEEK_SET);
@ -428,7 +428,7 @@ ImuseDigiSndMgr::SoundDesc *ImuseDigiSndMgr::openSound(int32 soundId, const char
char fileName[24]; char fileName[24];
int32 offset = 0, size = 0; int32 offset = 0, size = 0;
sprintf(fileName, "%s.map", soundName); sprintf(fileName, "%s.map", soundName);
Common::File *rmapFile = sound->bundle->getFile(fileName, offset, size); Common::SeekableReadStream *rmapFile = sound->bundle->getFile(fileName, offset, size);
if (!rmapFile) { if (!rmapFile) {
closeSound(sound); closeSound(sound);
return NULL; return NULL;
@ -666,7 +666,7 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte
sprintf(fileName, "%s_reg%03d", soundDesc->name, region); sprintf(fileName, "%s_reg%03d", soundDesc->name, region);
if (scumm_stricmp(fileName, soundDesc->lastFileName) != 0) { if (scumm_stricmp(fileName, soundDesc->lastFileName) != 0) {
int32 offs = 0, len = 0; int32 offs = 0, len = 0;
Common::File *cmpFile; Common::SeekableReadStream *cmpFile;
uint8 soundMode = 0; uint8 soundMode = 0;
sprintf(fileName, "%s_reg%03d.fla", soundDesc->name, region); sprintf(fileName, "%s_reg%03d.fla", soundDesc->name, region);

View file

@ -113,7 +113,7 @@ private:
bool checkForProperHandle(SoundDesc *soundDesc); bool checkForProperHandle(SoundDesc *soundDesc);
SoundDesc *allocSlot(); SoundDesc *allocSlot();
void prepareSound(byte *ptr, SoundDesc *sound); void prepareSound(byte *ptr, SoundDesc *sound);
void prepareSoundFromRMAP(Common::File *file, SoundDesc *sound, int32 offset, int32 size); void prepareSoundFromRMAP(Common::SeekableReadStream *file, SoundDesc *sound, int32 offset, int32 size);
ScummEngine *_vm; ScummEngine *_vm;
byte _disk; byte _disk;