1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "ags/engine/ac/dynobj/script_file.h"
24 #include "ags/engine/ac/global_file.h"
25
26 namespace AGS3 {
27
28 // CHECKME: actually NULLs here will be equal to kFile_Open & kFile_Read
29 const Shared::FileOpenMode sc_File::fopenModes[] =
30 { Shared::kFile_Open/*CHECKME, was undefined*/, Shared::kFile_Open, Shared::kFile_CreateAlways, Shared::kFile_Create };
31 const Shared::FileWorkMode sc_File::fworkModes[] =
32 { Shared::kFile_Read/*CHECKME, was undefined*/, Shared::kFile_Read, Shared::kFile_Write, Shared::kFile_Write };
33
Dispose(const char * address,bool force)34 int sc_File::Dispose(const char *address, bool force) {
35 Close();
36 delete this;
37 return 1;
38 }
39
GetType()40 const char *sc_File::GetType() {
41 return "File";
42 }
43
Serialize(const char * address,char * buffer,int bufsize)44 int sc_File::Serialize(const char *address, char *buffer, int bufsize) {
45 // we cannot serialize an open file, so it will get closed
46 return 0;
47 }
48
OpenFile(const char * filename,int mode)49 int sc_File::OpenFile(const char *filename, int mode) {
50 handle = FileOpen(filename, fopenModes[mode], fworkModes[mode]);
51 if (handle <= 0)
52 return 0;
53 return 1;
54 }
55
Close()56 void sc_File::Close() {
57 if (handle > 0) {
58 FileClose(handle);
59 handle = 0;
60 }
61 }
62
sc_File()63 sc_File::sc_File() {
64 handle = 0;
65 }
66
67
GetFieldPtr(const char * address,intptr_t offset)68 const char *sc_File::GetFieldPtr(const char *address, intptr_t offset) {
69 return address;
70 }
71
Read(const char * address,intptr_t offset,void * dest,int size)72 void sc_File::Read(const char *address, intptr_t offset, void *dest, int size) {
73 }
74
ReadInt8(const char * address,intptr_t offset)75 uint8_t sc_File::ReadInt8(const char *address, intptr_t offset) {
76 return 0;
77 }
78
ReadInt16(const char * address,intptr_t offset)79 int16_t sc_File::ReadInt16(const char *address, intptr_t offset) {
80 return 0;
81 }
82
ReadInt32(const char * address,intptr_t offset)83 int32_t sc_File::ReadInt32(const char *address, intptr_t offset) {
84 return 0;
85 }
86
ReadFloat(const char * address,intptr_t offset)87 float sc_File::ReadFloat(const char *address, intptr_t offset) {
88 return 0.0;
89 }
90
Write(const char * address,intptr_t offset,void * src,int size)91 void sc_File::Write(const char *address, intptr_t offset, void *src, int size) {
92 }
93
WriteInt8(const char * address,intptr_t offset,uint8_t val)94 void sc_File::WriteInt8(const char *address, intptr_t offset, uint8_t val) {
95 }
96
WriteInt16(const char * address,intptr_t offset,int16_t val)97 void sc_File::WriteInt16(const char *address, intptr_t offset, int16_t val) {
98 }
99
WriteInt32(const char * address,intptr_t offset,int32_t val)100 void sc_File::WriteInt32(const char *address, intptr_t offset, int32_t val) {
101 }
102
WriteFloat(const char * address,intptr_t offset,float val)103 void sc_File::WriteFloat(const char *address, intptr_t offset, float val) {
104 }
105
106 } // namespace AGS3
107