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 //=============================================================================
24 //
25 // Script File API implementation.
26 //
27 //=============================================================================
28 
29 #ifndef AGS_ENGINE_AC_FILE_H
30 #define AGS_ENGINE_AC_FILE_H
31 
32 #include "ags/engine/ac/dynobj/script_file.h"
33 #include "ags/engine/ac/runtime_defines.h"
34 
35 namespace AGS3 {
36 
37 using AGS::Shared::Stream;
38 
39 int     File_Exists(const char *fnmm);
40 int     File_Delete(const char *fnmm);
41 void *sc_OpenFile(const char *fnmm, int mode);
42 void    File_Close(sc_File *fil);
43 void    File_WriteString(sc_File *fil, const char *towrite);
44 void    File_WriteInt(sc_File *fil, int towrite);
45 void    File_WriteRawChar(sc_File *fil, int towrite);
46 void    File_WriteRawLine(sc_File *fil, const char *towrite);
47 void    File_ReadRawLine(sc_File *fil, char *buffer);
48 const char *File_ReadRawLineBack(sc_File *fil);
49 void    File_ReadString(sc_File *fil, char *toread);
50 const char *File_ReadStringBack(sc_File *fil);
51 int     File_ReadInt(sc_File *fil);
52 int     File_ReadRawChar(sc_File *fil);
53 int     File_ReadRawInt(sc_File *fil);
54 int     File_Seek(sc_File *fil, int offset, int origin);
55 int     File_GetEOF(sc_File *fil);
56 int     File_GetError(sc_File *fil);
57 int     File_GetPosition(sc_File *fil);
58 
59 struct ScriptFileHandle {
60 	Stream *stream;
61 	int32_t  handle;
62 };
63 extern ScriptFileHandle valid_handles[MAX_OPEN_SCRIPT_FILES + 1];
64 extern int num_open_script_files;
65 
66 ScriptFileHandle *check_valid_file_handle_ptr(Stream *stream_ptr, const char *operation_name);
67 ScriptFileHandle *check_valid_file_handle_int32(int32_t handle, const char *operation_name);
68 Stream *get_valid_file_stream_from_handle(int32_t handle, const char *operation_name);
69 
70 } // namespace AGS3
71 
72 #endif
73