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  * This file is based on WME Lite.
25  * http://dead-code.org/redir.php?target=wmelite
26  * Copyright (c) 2011 Jan Nedoma
27  */
28 
29 #ifndef WINTERMUTES_SXFILE_H
30 #define WINTERMUTES_SXFILE_H
31 
32 
33 #include "engines/wintermute/base/base_scriptable.h"
34 #include "common/stream.h"
35 
36 namespace Wintermute {
37 
38 class BaseFile;
39 
40 class SXFile : public BaseScriptable {
41 public:
42 	DECLARE_PERSISTENT(SXFile, BaseScriptable)
43 	ScValue *scGetProperty(const Common::String &name);
44 	bool scSetProperty(const char *name, ScValue *value);
45 	bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name);
46 	const char *scToString();
47 	SXFile(BaseGame *inGame, ScStack *Stack);
48 	virtual ~SXFile();
49 private:
50 	Common::SeekableReadStream *_readFile;
51 	Common::WriteStream *_writeFile;
52 	int32 _mode; // 0..none, 1..read, 2..write, 3..append
53 	bool _textMode;
54 	void close();
55 	void cleanup();
56 	uint32 getPos();
57 	uint32 getLength();
58 	bool setPos(uint32 pos, int whence = SEEK_SET);
59 	char *_filename;
60 	Common::WriteStream *openForWrite(const Common::String &filename, bool binary);
61 	Common::WriteStream *openForAppend(const Common::String &filename, bool binary);
62 };
63 
64 } // End of namespace Wintermute
65 
66 #endif
67