ScummVM API documentation
nuvie_io_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 NUVIE_FILES_NUVIE_IO_FILE_H
23 #define NUVIE_FILES_NUVIE_IO_FILE_H
24 
25 #include "ultima/shared/std/string.h"
26 #include "ultima/nuvie/files/nuvie_io.h"
27 #include "common/file.h"
28 #include "common/memstream.h"
29 #include "common/savefile.h"
30 
31 namespace Ultima {
32 namespace Nuvie {
33 
34 class NuvieIOFile : public NuvieIO {
35 public:
36  NuvieIOFile() {}
37  ~NuvieIOFile() override {}
38 
39  virtual bool open(const Common::Path &filename) {
40  return false;
41  };
42 };
43 
44 class NuvieIOFileRead : public NuvieIOFile {
45 private:
47  Common::File _srcFile;
48 public:
49  NuvieIOFileRead() : NuvieIOFile(), _file(nullptr) {}
50  ~NuvieIOFileRead() override;
51 
52  bool open(const Common::Path &filename) override;
53  virtual bool open(Common::InSaveFile *saveFile);
54  void close() override;
55  void seek(uint32 new_pos) override;
56 
57  uint8 read1() override;
58  uint16 read2() override;
59  uint32 read4() override;
60 
61  bool readToBuf(unsigned char *buf, uint32 buf_size) override;
62 
63  bool isOpen() const {
64  return _file != nullptr;
65  }
66 };
67 
75 class NuvieIOFileWrite : public NuvieIOFile {
76 private:
78  Common::DumpFile _dumpFile;
79  Common::OutSaveFile *_saveFile;
81  Common::String _description;
82  bool _isAutosave;
83 protected:
84  bool isOpen() const {
85  return _file != nullptr;
86  }
87 public:
89  ~NuvieIOFileWrite() override;
90  bool open(const Common::Path &filename) override;
91  bool open(const Common::String &filename, bool isAutosave);
92  void close() override;
93  void seek(uint32 new_pos) override;
94 
95  bool write1(uint8 src) override;
96  bool write2(uint16 src) override;
97  bool write4(uint32 src) override;
98  void writeDesc(const Common::String &desc) {
99  _description = desc;
100  }
101 
102  uint32 writeBuf(const unsigned char *src, uint32 src_size) override;
103  uint32 write(NuvieIO *src) override;
104 };
105 
106 } // End of namespace Nuvie
107 } // End of namespace Ultima
108 
109 #endif
Definition: str.h:59
Definition: savefile.h:54
Definition: memstream.h:194
Definition: path.h:52
Definition: stream.h:745
Definition: file.h:145
Definition: nuvie_io_file.h:75
Definition: detection.h:27
Definition: file.h:47
Definition: stream.h:351
Definition: nuvie_io_file.h:34
Definition: nuvie_io.h:32
Definition: nuvie_io_file.h:44