Debian Codegraph @

Source/Core/DiscIO/CISOBlob.h

raw symbols SCIP
1 // Copyright 2008 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <memory>
7 #include <string>
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 CISO_MAGIC = 0x4F534943; // "CISO" (byteswapped to little endian)
16
17 static constexpr u32 CISO_HEADER_SIZE = 0x8000;
18 static constexpr u32 CISO_MAP_SIZE = CISO_HEADER_SIZE - sizeof(u32) - sizeof(char) * 4;
19
20 struct CISOHeader
21 {
22 // "CISO"
23 u32 magic;
24
25 // little endian
26 u32 block_size;
27
28 // 0=unused, 1=used, others=invalid
29 u8 map[CISO_MAP_SIZE];
30 };
31
32 class CISOFileReader final : public BlobReader
33 {
34 public:
35 static std::unique_ptr<CISOFileReader> Create(File::DirectIOFile file);
36
37 BlobType GetBlobType() const override { return BlobType::CISO; }
38 std::unique_ptr<BlobReader> CopyReader() const override;
39
40 u64 GetRawSize() const override;
41 u64 GetDataSize() const override;
42 DataSizeType GetDataSizeType() const override { return DataSizeType::UpperBound; }
43
44 u64 GetBlockSize() const override { return m_block_size; }
45 bool HasFastRandomAccessInBlock() const override { return true; }
46 std::string GetCompressionMethod() const override { return {}; }
47 std::optional<int> GetCompressionLevel() const override { return std::nullopt; }
48
49 bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
50
51 private:
52 CISOFileReader(File::DirectIOFile file);
53
54 typedef u16 MapType;
55 static constexpr MapType UNUSED_BLOCK_ID = UINT16_MAX;
56
57 File::DirectIOFile m_file;
58 u64 m_size;
59 u32 m_block_size;
60 MapType m_ciso_map[CISO_MAP_SIZE];
61 };
62
63 } // namespace DiscIO