ScummVM API documentation
File.h
1 /* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
2  * Copyright (C) 2011-2022 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 2.1 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MT32EMU_FILE_H
19 #define MT32EMU_FILE_H
20 
21 #include <cstddef>
22 
23 #include "globals.h"
24 #include "Types.h"
25 
26 namespace MT32Emu {
27 
28 class MT32EMU_EXPORT File {
29 public:
30  // Includes terminator char.
31  typedef char SHA1Digest[41];
32 
33  virtual ~File() {}
34  virtual size_t getSize() = 0;
35  virtual const Bit8u *getData() = 0;
36  virtual const SHA1Digest &getSHA1() = 0;
37 
38  virtual void close() = 0;
39 };
40 
41 class MT32EMU_EXPORT AbstractFile : public File {
42 public:
43  const SHA1Digest &getSHA1();
44 
45 protected:
46  AbstractFile();
47  AbstractFile(const SHA1Digest &sha1Digest);
48 
49 private:
50  bool sha1DigestCalculated;
51  SHA1Digest sha1Digest;
52 
53  // Binary compatibility helper.
54  void *reserved;
55 };
56 
57 class MT32EMU_EXPORT ArrayFile : public AbstractFile {
58 public:
59  ArrayFile(const Bit8u *data, size_t size);
60  ArrayFile(const Bit8u *data, size_t size, const SHA1Digest &sha1Digest);
61 
62  size_t getSize();
63  const Bit8u *getData();
64  void close() {}
65 
66 private:
67  const Bit8u *data;
68  size_t size;
69 };
70 
71 } // namespace MT32Emu
72 
73 #endif // #ifndef MT32EMU_FILE_H
Definition: Analog.h:26
Definition: File.h:41
Definition: File.h:57
Definition: File.h:28