aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-06-21 20:27:48 +0000
committerMax Horn2003-06-21 20:27:48 +0000
commit1465598aad62650d904652b367ad4fe7157252f1 (patch)
treeded67f87ecdb4dbbae24803e98d86d4ea2dc2e11 /scumm
parent2db275b1096cd00c61498dc5c264149e6e6c9458 (diff)
downloadscummvm-rg350-1465598aad62650d904652b367ad4fe7157252f1.tar.gz
scummvm-rg350-1465598aad62650d904652b367ad4fe7157252f1.tar.bz2
scummvm-rg350-1465598aad62650d904652b367ad4fe7157252f1.zip
finally implemented this TODO: using class File instead of fopen
svn-id: r8588
Diffstat (limited to 'scumm')
-rw-r--r--scumm/script_v5.cpp39
1 files changed, 13 insertions, 26 deletions
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index bfb803d223..ef2ab20366 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -1755,50 +1755,37 @@ void Scumm_v5::o5_roomOps() {
break;
case 13:{ /* save-string */
- // TODO - use class File instead of fopen/fwrite/fclose
- char buf[256], *s;
- FILE *out;
+ File file;
+ char filename[256], *s;
a = getVarOrDirectByte(0x80);
- // FIXME - check for buffer overflow
- strcpy(buf, getSavePath());
- s = buf + strlen(buf);
+ s = filename;
while ((*s++ = fetchScriptByte()));
- // Use buf as filename
- out = fopen(buf, "wb");
- if (out) {
+ file.open(filename, getSavePath(), File::kFileWriteMode);
+ if (file.isOpen()) {
byte *ptr;
ptr = getResourceAddress(rtString, a);
- fwrite(ptr, resStrLen(ptr) + 1, 1, out);
- fclose(out);
+ file.write(ptr, resStrLen(ptr) + 1);
}
break;
}
case 14:{ /* load-string */
- // TODO - use class File instead of fopen/fread/fclose
- char buf[256], *s;
- FILE *in;
+ File file;
+ char filename[256], *s;
a = getVarOrDirectByte(0x80);
- // FIXME - check for buffer overflow
- strcpy(buf, getSavePath());
- s = buf + strlen(buf);
+ s = filename;
while ((*s++ = fetchScriptByte()));
- // Use buf as filename
- in = fopen(buf, "rb");
- if (in) {
+ file.open(filename, getSavePath(), File::kFileReadMode);
+ if (file.isOpen()) {
byte *ptr;
- int len;
- fseek(in, 0, SEEK_END);
- len = ftell(in); // Determine file size
+ int len = file.size();
ptr = (byte *)calloc(len + 1, 1); // Create a zero terminated buffer
- fseek(in, 0, SEEK_SET);
- fread(ptr, len, 1, in); // Read in the data
- fclose(in);
+ file.read(ptr, len); // Read in the data
loadPtrToResource(rtString, a, ptr);
free(ptr);
}