aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/dataio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/dataio.cpp')
-rw-r--r--engines/gob/dataio.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/engines/gob/dataio.cpp b/engines/gob/dataio.cpp
index a37586aee6..f59fa80e8d 100644
--- a/engines/gob/dataio.cpp
+++ b/engines/gob/dataio.cpp
@@ -239,7 +239,7 @@ int16 DataIO::getChunk(const char *chunkName) {
}
dataDesc = _dataFiles[file];
- for (int16 chunk = 0; chunk < _numDataChunks[file]; chunk++, dataDesc++) {
+ for (uint16 chunk = 0; chunk < _numDataChunks[file]; chunk++, dataDesc++) {
if (scumm_stricmp(chunkName, dataDesc->chunkName) != 0)
continue;
@@ -334,7 +334,6 @@ uint32 DataIO::getChunkPos(int16 handle) const {
int32 DataIO::getChunkSize(const char *chunkName) {
int16 file;
- int16 chunk;
struct ChunkDesc *dataDesc;
int16 slot;
int32 realSize;
@@ -344,7 +343,7 @@ int32 DataIO::getChunkSize(const char *chunkName) {
return -1;
dataDesc = _dataFiles[file];
- for (chunk = 0; chunk < _numDataChunks[file]; chunk++, dataDesc++) {
+ for (uint16 chunk = 0; chunk < _numDataChunks[file]; chunk++, dataDesc++) {
if (scumm_stricmp(chunkName, dataDesc->chunkName) != 0)
continue;
@@ -488,6 +487,16 @@ int16 DataIO::openData(const char *path) {
return file_open(path);
}
+bool DataIO::existData(const char *path) {
+ int16 handle = openData(path);
+
+ if (handle < 0)
+ return false;
+
+ closeData(handle);
+ return true;
+}
+
DataStream *DataIO::openAsStream(int16 handle, bool dispose) {
uint32 curPos = getPos(handle);
seekData(handle, 0, SEEK_END);
@@ -575,6 +584,9 @@ byte *DataIO::getData(const char *path) {
}
DataStream *DataIO::getDataStream(const char *path) {
+ if (!path || (path[0] == '\0') || !existData(path))
+ return 0;
+
uint32 size = getDataSize(path);
byte *data = getData(path);