[Scummvm-git-logs] scummvm master -> f995021d04e2b15aeacf1f47df3fc29ff294fde8
sev-
noreply at scummvm.org
Mon May 5 09:23:51 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
f995021d04 AWE: Eliminated thin wrapper around Common::File
Commit: f995021d04e2b15aeacf1f47df3fc29ff294fde8
https://github.com/scummvm/scummvm/commit/f995021d04e2b15aeacf1f47df3fc29ff294fde8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2025-05-05T11:23:33+02:00
Commit Message:
AWE: Eliminated thin wrapper around Common::File
And celebrating the merge of the engine, after 21 years!
Referring to e29ec6e79c325bcea2c95ecbfeb3a64c80a30630
Changed paths:
R engines/awe/file.cpp
R engines/awe/file.h
engines/awe/aifc_player.h
engines/awe/engine.cpp
engines/awe/module.mk
engines/awe/pak.cpp
engines/awe/pak.h
engines/awe/resource.cpp
engines/awe/resource_3do.cpp
engines/awe/resource_3do.h
engines/awe/resource_nth.cpp
engines/awe/resource_win31.cpp
engines/awe/resource_win31.h
diff --git a/engines/awe/aifc_player.h b/engines/awe/aifc_player.h
index 4beb30f4a3f..6a316389cea 100644
--- a/engines/awe/aifc_player.h
+++ b/engines/awe/aifc_player.h
@@ -22,13 +22,14 @@
#ifndef AWE_AIFC_PLAYER_H
#define AWE_AIFC_PLAYER_H
+#include "common/file.h"
+
#include "awe/intern.h"
-#include "awe/file.h"
namespace Awe {
struct AifcPlayer {
- File _f;
+ Common::File _f;
uint32 _ssndOffset = 0;
uint32 _ssndSize = 0;
uint32 _pos = 0;
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index edd1ca139a2..6f284eeb350 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -20,7 +20,6 @@
*/
#include "awe/engine.h"
-#include "awe/file.h"
#include "awe/gfx.h"
#include "awe/resource_nth.h"
#include "awe/system_stub.h"
diff --git a/engines/awe/file.cpp b/engines/awe/file.cpp
deleted file mode 100644
index 738fc152bde..00000000000
--- a/engines/awe/file.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/* ScummVM - Graphic Adventure AweEngine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "awe/file.h"
-
-namespace Awe {
-
-#ifdef DEPRECATED
-struct File_impl {
- bool _ioErr;
- File_impl() : _ioErr(false) {
- }
- virtual ~File_impl() {
- }
- virtual bool open(const char *path, const char *mode) = 0;
- virtual void close() = 0;
- virtual uint32 size() = 0;
- virtual void seek(int off, int whence) = 0;
- virtual int read(void *ptr, uint32 len) = 0;
- virtual int write(void *ptr, uint32 len) = 0;
-};
-
-struct stdFile : File_impl {
- FILE *_fp;
- stdFile() : _fp(0) {
- }
- bool open(const char *path, const char *mode) {
- _ioErr = false;
- _fp = fopen(path, mode);
- return (_fp != 0);
- }
- void close() {
- if (_fp) {
- fclose(_fp);
- _fp = 0;
- }
- }
- uint32 size() {
- uint32 sz = 0;
- if (_fp) {
- int pos = ftell(_fp);
- fseek(_fp, 0, SEEK_END);
- sz = ftell(_fp);
- fseek(_fp, pos, SEEK_SET);
- }
- return sz;
- }
- void seek(int off, int whence) {
- if (_fp) {
- fseek(_fp, off, whence);
- }
- }
- int read(void *ptr, uint32 len) {
- if (_fp) {
- uint32 r = fread(ptr, 1, len, _fp);
- if (r != len) {
- _ioErr = true;
- }
- return r;
- }
- return 0;
- }
- int write(void *ptr, uint32 len) {
- if (_fp) {
- uint32 r = fwrite(ptr, 1, len, _fp);
- if (r != len) {
- _ioErr = true;
- }
- return r;
- }
- return 0;
- }
-};
-
-File::File() {
- _impl = new stdFile;
-}
-
-File::~File() {
- _impl->close();
- delete _impl;
-}
-
-bool File::open(const char *filepath) {
- _impl->close();
- return _impl->open(filepath, "rb");
-}
-
-static bool getFilePathNoCase(const char *filename, const char *path, char *out) {
- bool ret = false;
- DIR *d = opendir(path);
- if (d) {
- dirent *de;
- while ((de = readdir(d)) != NULL) {
- if (de->d_name[0] == '.') {
- continue;
- }
- if (strcasecmp(de->d_name, filename) == 0) {
- sprintf(out, "%s/%s", path, de->d_name);
- ret = true;
- break;
- }
- }
- closedir(d);
- }
- return ret;
-}
-
-bool File::open(const char *filename, const char *path) {
- _impl->close();
- char filepath[MAXPATHLEN];
- if (getFilePathNoCase(filename, path, filepath)) {
- return _impl->open(filepath, "rb");
- }
- return false;
-}
-
-bool File::openForWriting(const char *filepath) {
- _impl->close();
- return _impl->open(filepath, "wb");
-}
-
-void File::close() {
- _impl->close();
-}
-
-bool File::ioErr() const {
- return _impl->_ioErr;
-}
-
-uint32 File::size() {
- return _impl->size();
-}
-
-void File::seek(int off, int whence) {
- _impl->seek(off, whence);
-}
-
-int File::read(void *ptr, uint32 len) {
- return _impl->read(ptr, len);
-}
-
-uint8 File::readByte() {
- uint8 b;
- read(&b, 1);
- return b;
-}
-
-uint16 File::readUint16LE() {
- uint8 lo = readByte();
- uint8 hi = readByte();
- return (hi << 8) | lo;
-}
-
-uint32 File::readUint32LE() {
- uint16 lo = readUint16LE();
- uint16 hi = readUint16LE();
- return (hi << 16) | lo;
-}
-
-uint16 File::readUint16BE() {
- uint8 hi = readByte();
- uint8 lo = readByte();
- return (hi << 8) | lo;
-}
-
-uint32 File::readUint32BE() {
- uint16 hi = readUint16BE();
- uint16 lo = readUint16BE();
- return (hi << 16) | lo;
-}
-
-int File::write(void *ptr, uint32 len) {
- return _impl->write(ptr, len);
-}
-
-void File::writeByte(uint8 b) {
- write(&b, 1);
-}
-
-void File::writeUint16LE(uint16 n) {
- writeByte(n & 0xFF);
- writeByte(n >> 8);
-}
-
-void File::writeUint32LE(uint32 n) {
- writeUint16LE(n & 0xFFFF);
- writeUint16LE(n >> 16);
-}
-
-void File::writeUint16BE(uint16 n) {
- writeByte(n >> 8);
- writeByte(n & 0xFF);
-}
-
-void File::writeUint32BE(uint32 n) {
- writeUint16BE(n >> 16);
- writeUint16BE(n & 0xFFFF);
-}
-
-void dumpFile(const char *filename, const uint8 *p, int size) {
- char path[MAXPATHLEN];
- snprintf(path, sizeof(path), "DUMP/%s", filename);
- FILE *fp = fopen(path, "wb");
- if (fp) {
- const int wr = fwrite(p, 1, size, fp);
- if (wr != size) {
- warning("Failed to write %d bytes (expected %d)", wr, size);
- }
- fclose(fp);
- }
-}
-#endif
-
-void dumpFile(const char *filename, const uint8 *p, int size) {
- error("TODO: dumpFile - %s", filename);
-}
-
-} // namespace Awe
diff --git a/engines/awe/file.h b/engines/awe/file.h
deleted file mode 100644
index 8865559efb2..00000000000
--- a/engines/awe/file.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AWE_FILE_H
-#define AWE_FILE_H
-
-#include "common/file.h"
-
-namespace Awe {
-
-class File : public Common::File {
-public:
- bool open(const char *filename, const char *path = nullptr) {
- return Common::File::open(Common::Path(filename));
- }
-
- bool ioErr() const {
- return Common::File::err();
- }
-};
-
-#ifdef DEPRECATED
-struct File_impl;
-
-struct File {
- File();
- ~File();
-
- File_impl *_impl;
-
- bool open(const char *filepath);
- bool open(const char *filename, const char *path);
- bool openForWriting(const char *filepath);
- void close();
- bool ioErr() const;
- uint32 size();
- void seek(int off, int whence = SEEK_SET);
- int read(void *ptr, uint32 len);
- uint8 readByte();
- uint16 readUint16LE();
- uint32 readUint32LE();
- uint16 readUint16BE();
- uint32 readUint32BE();
- int write(void *ptr, uint32 size);
- void writeByte(uint8 b);
- void writeUint16LE(uint16 n);
- void writeUint32LE(uint32 n);
- void writeUint16BE(uint16 n);
- void writeUint32BE(uint32 n);
-};
-
-#endif
-
-void dumpFile(const char *filename, const uint8 *p, int size);
-
-} // namespace Awe
-
-#endif
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index a162af93d24..463f853ba40 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -7,7 +7,6 @@ MODULE_OBJS = \
bitmap.o \
detection.o \
engine.o \
- file.o \
graphics_gl.o \
graphics_soft.o \
metaengine.o \
diff --git a/engines/awe/pak.cpp b/engines/awe/pak.cpp
index 99369291325..a27a501d1ce 100644
--- a/engines/awe/pak.cpp
+++ b/engines/awe/pak.cpp
@@ -55,7 +55,7 @@ Pak::~Pak() {
}
void Pak::open(const char *dataPath) {
- _f.open(FILENAME, dataPath);
+ _f.open(Common::Path(FILENAME));
}
void Pak::close() {
@@ -73,7 +73,7 @@ void Pak::readEntries() {
memset(header, 0, sizeof(header));
_f.read(header, sizeof(header));
- if (_f.ioErr() || memcmp(header, "PACK", 4) != 0) {
+ if (_f.err() || memcmp(header, "PACK", 4) != 0) {
return;
}
const uint32 entriesOffset = READ_LE_UINT32(header + 4);
@@ -89,7 +89,7 @@ void Pak::readEntries() {
for (int i = 0; i < _entriesCount; ++i) {
uint8 buf[0x40];
_f.read(buf, sizeof(buf));
- if (_f.ioErr()) {
+ if (_f.err()) {
break;
}
const char *name = (const char *)buf;
@@ -129,7 +129,7 @@ const PakEntry *Pak::find(const char *name) {
void Pak::loadData(const PakEntry *e, uint8 *buf, uint32 *size) {
debugC(kDebugPak, "Pak::loadData() %d bytes from 0x%x", e->size, e->offset);
_f.seek(e->offset);
- if (_f.ioErr()) {
+ if (_f.err()) {
*size = 0;
return;
}
diff --git a/engines/awe/pak.h b/engines/awe/pak.h
index 45c5e00dd3d..8389ed37e6e 100644
--- a/engines/awe/pak.h
+++ b/engines/awe/pak.h
@@ -22,8 +22,9 @@
#ifndef AWE_PAK_H
#define AWE_PAK_H
+#include "common/file.h"
+
#include "awe/intern.h"
-#include "awe/file.h"
namespace Awe {
@@ -36,7 +37,7 @@ struct PakEntry {
struct Pak {
static const char *FILENAME;
- File _f;
+ Common::File _f;
PakEntry *_entries = nullptr;
int _entriesCount = 0;
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index ed80d54078f..c35773a9e44 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -21,7 +21,6 @@
#include "common/config-manager.h"
#include "awe/resource.h"
-#include "awe/file.h"
#include "awe/pak.h"
#include "awe/resource_nth.h"
#include "awe/resource_win31.h"
@@ -60,7 +59,7 @@ bool Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
bool ret = false;
char name[10];
snprintf(name, sizeof(name), "%s%02x", _bankPrefix, me->bankNum);
- File f;
+ Common::File f;
if (f.open(name) || (_dataType == DT_ATARI_DEMO && f.open(atariDemo))) {
f.seek(me->bankPos);
const size_t count = f.read(dstBuf, me->packedSize);
@@ -181,7 +180,7 @@ void Resource::readEntries() {
break;
case DT_ATARI_DEMO:
{
- File f;
+ Common::File f;
if (f.open(atariDemo)) {
static const struct {
uint8 type;
@@ -237,7 +236,7 @@ void Resource::dumpEntries() {
if (readBank(&_memList[i], p)) {
char name[16];
snprintf(name, sizeof(name), "data_%02x_%d", i, _memList[i].type);
- dumpFile(name, p, _memList[i].unpackedSize);
+ //dumpFile(name, p, _memList[i].unpackedSize);
}
free(p);
}
@@ -655,7 +654,7 @@ void Resource::freeMemBlock() {
void Resource::readDemo3Joy() {
static const char *filename = "demo3.joy";
- File f;
+ Common::File f;
if (f.open(filename)) {
const uint32 fileSize = f.size();
_demo3Joy.bufPtr = (uint8 *)malloc(fileSize);
diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
index f2579cf2a06..1bdfca20c24 100644
--- a/engines/awe/resource_3do.cpp
+++ b/engines/awe/resource_3do.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/file.h"
+
#include "awe/resource_3do.h"
namespace Awe {
@@ -44,7 +46,7 @@ static int decodeLzss(const uint8 *src, uint32 len, uint8 *dst) {
return wr;
}
-static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32 dataSize, uint16 *dst) {
+static void decodeCcb16(int ccbWidth, int ccbHeight, Common::File *f, uint32 dataSize, uint16 *dst) {
for (int y = 0; y < ccbHeight; ++y) {
const int scanlineSize = 4 * (f->readUint16BE() + 2);
int scanlineLen = 2;
@@ -77,7 +79,7 @@ static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32 dataSize, u
scanlineLen += 2;
}
break;
-
+
default:
break;
}
@@ -98,7 +100,7 @@ static const uint8 _ccb_bppTable[8] = {
0, 1, 2, 4, 6, 8, 16, 0
};
-static uint16 *decodeShapeCcb(File *f, int dataSize, int *w, int *h) {
+static uint16 *decodeShapeCcb(Common::File *f, int dataSize, int *w, int *h) {
const uint32 flags = f->readUint32BE();
f->seek(4, SEEK_CUR);
const uint32 celData = f->readUint32BE();
@@ -129,7 +131,7 @@ uint8 *Resource3do::loadFile(int num, uint8 *dst, uint32 *size) {
char path[MAXPATHLEN];
snprintf(path, sizeof(path), "GameData/File%d", num);
- File f;
+ Common::File f;
if (f.open(path)) {
const int sz = f.size();
if (!dst) {
@@ -169,7 +171,7 @@ uint8 *Resource3do::loadFile(int num, uint8 *dst, uint32 *size) {
uint16 *Resource3do::loadShape555(const char *name, int *w, int *h) {
char path[MAXPATHLEN];
snprintf(path, sizeof(path), "GameData/%s", name);
- File f;
+ Common::File f;
if (f.open(path)) {
const uint32 dataSize = f.size();
return decodeShapeCcb(&f, dataSize, w, h);
diff --git a/engines/awe/resource_3do.h b/engines/awe/resource_3do.h
index a0de15ccdec..9b399128974 100644
--- a/engines/awe/resource_3do.h
+++ b/engines/awe/resource_3do.h
@@ -23,7 +23,6 @@
#define AWE_RESOURCE_3DO_H
#include "awe/intern.h"
-#include "awe/file.h"
namespace Awe {
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index ec0b7a2a648..efc680f6542 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -27,7 +27,7 @@
namespace Awe {
-static char *loadTextFile(File &f, const int size) {
+static char *loadTextFile(Common::File &f, const int size) {
char *buf = (char *)malloc(size + 1);
if (buf) {
const int count = f.read(buf, size);
@@ -160,7 +160,7 @@ struct Resource15th : ResourceNth {
}
char path[MAXPATHLEN];
snprintf(path, sizeof(path), "%s/lang_%s", _menuPath, name);
- File f;
+ Common::File f;
if (f.open(path)) {
const int size = f.size();
_textBuf = loadTextFile(f, size);
@@ -218,7 +218,7 @@ struct Resource15th : ResourceNth {
path = "Music/AW/End2004.wav";
}
break;
-
+
default:
break;
}
@@ -232,7 +232,7 @@ struct Resource15th : ResourceNth {
};
static uint8 *inflateGzip(const char *filepath) {
- File f;
+ Common::File f;
if (!f.open(filepath)) {
warning("Unable to open '%s'", filepath);
return nullptr;
@@ -262,7 +262,7 @@ static uint8 *inflateGzip(const char *filepath) {
str.next_out = out;
str.avail_out = dataSize;
while (err == Z_OK && str.avail_out != 0) {
- if (str.avail_in == 0 && !f.ioErr()) {
+ if (str.avail_in == 0 && !f.err()) {
str.next_in = buf;
str.avail_in = f.read(buf, sizeof(buf));
}
@@ -381,13 +381,13 @@ struct Resource20th : ResourceNth {
char path[MAXPATHLEN];
Common::strcpy_s(path, "game/DAT");
- File f;
+ Common::File f;
if (_datName[0]) {
- datOpen = f.open(_datName, path);
+ datOpen = f.open(_datName);
}
if (!datOpen) {
snprintf(_datName, sizeof(_datName), "FILE%03d.DAT", num);
- datOpen = f.open(_datName, path);
+ datOpen = f.open(_datName);
}
if (datOpen) {
const uint32 dataSize = f.size();
@@ -498,7 +498,7 @@ struct Resource20th : ResourceNth {
nullptr
};
bool isOpen = false;
- File f;
+ Common::File f;
for (int i = 0; fmt[i] && !isOpen; ++i) {
snprintf(path, sizeof(path), fmt[i], name);
isOpen = f.open(path);
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index 9090eacec31..1b4f23d740f 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -55,7 +55,7 @@ static uint16 decode(uint8 *p, int size, uint16 key) {
}
struct Bitstream {
- File *_f;
+ Common::File *_f;
int _size;
uint16 _bits;
int _len;
@@ -64,7 +64,7 @@ struct Bitstream {
: _f(nullptr), _size(0), _bits(0), _len(0) {
}
- void reset(File *f, int size) {
+ void reset(Common::File *f, int size) {
_f = f;
_size = size;
_bits = 0;
@@ -237,7 +237,7 @@ struct LzHuffman {
return currentSize == uncompressedSize;
}
- bool decompressEntry(File &f, const Win31BankEntry *e, uint8 *out) {
+ bool decompressEntry(Common::File &f, const Win31BankEntry *e, uint8 *out) {
f.seek(e->offset);
_stream.reset(&f, e->packedSize);
return decode(out, e->size);
@@ -299,7 +299,7 @@ uint8 *ResourceWin31::loadFile(int num, uint8 *dst, uint32 *size) {
// check for unpacked data
char name[32];
snprintf(name, sizeof(name), "%03d_%s", num, e->name);
- File f;
+ Common::File f;
if (f.open(name) && f.size() == e->size) {
f.read(dst, e->size);
return dst;
diff --git a/engines/awe/resource_win31.h b/engines/awe/resource_win31.h
index cb8dd0156bb..b7a67c8c8a1 100644
--- a/engines/awe/resource_win31.h
+++ b/engines/awe/resource_win31.h
@@ -22,8 +22,9 @@
#ifndef AWE_RESOURCE_WIN31_H
#define AWE_RESOURCE_WIN31_H
+#include "common/file.h"
+
#include "awe/intern.h"
-#include "awe/file.h"
namespace Awe {
@@ -38,7 +39,7 @@ struct Win31BankEntry {
struct ResourceWin31 {
static const char *FILENAME;
- File _f;
+ Common::File _f;
Win31BankEntry *_entries = nullptr;
int _entriesCount = 0;
uint8 *_textBuf = nullptr;
More information about the Scummvm-git-logs
mailing list