Debian Codegraph @

Source/Core/DiscIO/TGCBlob.h

raw symbols SCIP
1 // Copyright 2016 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <memory>
7 #include <vector>
8
9 #include "Common/CommonTypes.h"
10 #include "Common/DirectIOFile.h"
11 #include "DiscIO/Blob.h"
12
13 namespace DiscIO
14 {
15 static constexpr u32 TGC_MAGIC = 0xA2380FAE;
16
17 struct TGCHeader
18 {
19 u32 magic;
20 u32 unknown_1;
21 u32 tgc_header_size;
22 u32 disc_header_area_size;
23
24 u32 fst_real_offset;
25 u32 fst_size;
26 u32 fst_max_size;
27 u32 dol_real_offset;
28
29 u32 dol_size;
30 u32 file_area_real_offset;
31 u32 unknown_2;
32 u32 unknown_3;
33
34 u32 unknown_4;
35 u32 file_area_virtual_offset;
36 };
37
38 class TGCFileReader final : public BlobReader
39 {
40 public:
41 static std::unique_ptr<TGCFileReader> Create(File::DirectIOFile file);
42
43 BlobType GetBlobType() const override { return BlobType::TGC; }
44 std::unique_ptr<BlobReader> CopyReader() const override;
45
46 u64 GetRawSize() const override { return m_size; }
47 u64 GetDataSize() const override;
48 DataSizeType GetDataSizeType() const override { return DataSizeType::Accurate; }
49
50 u64 GetBlockSize() const override { return 0; }
51 bool HasFastRandomAccessInBlock() const override { return true; }
52 std::string GetCompressionMethod() const override { return {}; }
53 std::optional<int> GetCompressionLevel() const override { return std::nullopt; }
54
55 bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
56
57 private:
58 TGCFileReader(File::DirectIOFile file);
59
60 File::DirectIOFile m_file;
61 u64 m_size;
62
63 std::vector<u8> m_fst;
64
65 // Stored as big endian in memory, regardless of the host endianness
66 TGCHeader m_header = {};
67 };
68
69 } // namespace DiscIO