ScummVM API documentation
scummvm_file.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef LUA_SCUMMVM_FILE_H
23 #define LUA_SCUMMVM_FILE_H
24 
25 #include "common/str.h"
26 #include "common/file.h"
27 
28 namespace Lua {
29 
30 class LuaFileProxy {
31 public:
32  static LuaFileProxy *create(const Common::String &filename, const Common::String &mode);
33 public:
34  virtual ~LuaFileProxy() {}
35  virtual bool eof() const = 0;
36  virtual size_t read(void *ptr, size_t size, size_t count) = 0;
37  virtual size_t write(const char *ptr, size_t count) = 0;
38 };
39 
44 class LuaFileConfig : public LuaFileProxy {
45  friend class LuaFileProxy;
46 private:
47  Common::String _readData;
48  uint _readPos;
49  Common::String _settings;
50 
51  Common::String formatDouble(double value);
52  void setupConfigFile();
53  Common::String getLanguage();
54  void setLanguage(const Common::String &lang);
55  void writeSettings();
56  void updateSetting(const Common::String &setting, const Common::String &value);
57 
58  LuaFileConfig(const Common::String &filename, const Common::String &mode);
59 public:
60  virtual ~LuaFileConfig();
61 
62  bool eof() const override { return _readPos >= _readData.size(); }
63  size_t read(void *ptr, size_t size, size_t count) override;
64  size_t write(const char *ptr, size_t count) override;
65 };
66 
67 class LuaFileRead : public LuaFileProxy {
68 private:
69  Common::File _file;
70  int32 _size;
71 public:
72  LuaFileRead(const Common::Path &filename, const Common::String &mode);
73 public:
74  virtual ~LuaFileRead() {}
75 
76  bool eof() const override;
77  size_t read(void *ptr, size_t size, size_t count) override;
78  size_t write(const char *ptr, size_t count) override;
79 };
80 
81 } // End of namespace Lua
82 
83 #endif
Definition: str.h:59
Definition: path.h:52
Definition: scummvm_file.h:44
Definition: lua_persistence.h:57
Definition: file.h:47
Definition: scummvm_file.h:30
Definition: scummvm_file.h:67