| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <map> |
| 7 |
#include <memory> |
| 8 |
#include <string> |
| 9 |
#include <string_view> |
| 10 |
#include <vector> |
| 11 |
|
| 12 |
#include "Common/CommonTypes.h" |
| 13 |
#include "DiscIO/Filesystem.h" |
| 14 |
|
| 15 |
namespace DiscIO |
| 16 |
{ |
| 17 |
class VolumeDisc; |
| 18 |
struct Partition; |
| 19 |
|
| 20 |
class FileInfoGCWii final : public FileInfo |
| 21 |
{ |
| 22 |
public: |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
FileInfoGCWii(const u8* fst, u8 offset_shift, u32 index, u32 total_file_infos); |
| 27 |
|
| 28 |
FileInfoGCWii(const u8* fst, u8 offset_shift); |
| 29 |
|
| 30 |
FileInfoGCWii(const FileInfoGCWii& file_info) = default; |
| 31 |
|
| 32 |
FileInfoGCWii(const FileInfoGCWii& file_info, u32 index); |
| 33 |
|
| 34 |
~FileInfoGCWii() override; |
| 35 |
|
| 36 |
std::unique_ptr<FileInfo> clone() const override; |
| 37 |
const_iterator begin() const override; |
| 38 |
const_iterator end() const override; |
| 39 |
|
| 40 |
u64 GetOffset() const override; |
| 41 |
u32 GetSize() const override; |
| 42 |
bool IsRoot() const override; |
| 43 |
bool IsDirectory() const override; |
| 44 |
u32 GetTotalChildren() const override; |
| 45 |
std::string GetName() const override; |
| 46 |
bool NameCaseInsensitiveEquals(std::string_view other) const override; |
| 47 |
std::string GetPath() const override; |
| 48 |
|
| 49 |
bool IsValid(u64 fst_size, const FileInfoGCWii& parent_directory) const; |
| 50 |
|
| 51 |
protected: |
| 52 |
uintptr_t GetAddress() const override; |
| 53 |
FileInfo& operator++() override; |
| 54 |
|
| 55 |
private: |
| 56 |
enum class EntryProperty |
| 57 |
{ |
| 58 |
|
| 59 |
|
| 60 |
NAME_OFFSET = 0, |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
FILE_OFFSET = 1, |
| 65 |
|
| 66 |
|
| 67 |
FILE_SIZE = 2 |
| 68 |
}; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
u32 GetNextIndex() const; |
| 73 |
|
| 74 |
|
| 75 |
u32 Get(EntryProperty entry_property) const; |
| 76 |
|
| 77 |
u64 GetNameOffset() const; |
| 78 |
|
| 79 |
const u8* m_fst; |
| 80 |
u8 m_offset_shift; |
| 81 |
u32 m_index; |
| 82 |
u32 m_total_file_infos; |
| 83 |
}; |
| 84 |
|
| 85 |
class FileSystemGCWii final : public FileSystem |
| 86 |
{ |
| 87 |
public: |
| 88 |
FileSystemGCWii(const VolumeDisc* volume, const Partition& partition); |
| 89 |
~FileSystemGCWii() override; |
| 90 |
|
| 91 |
bool IsValid() const override { return m_valid; } |
| 92 |
const FileInfo& GetRoot() const override; |
| 93 |
std::unique_ptr<FileInfo> FindFileInfo(std::string_view path) const override; |
| 94 |
std::unique_ptr<FileInfo> FindFileInfo(u64 disc_offset) const override; |
| 95 |
|
| 96 |
private: |
| 97 |
bool m_valid; |
| 98 |
std::vector<u8> m_file_system_table; |
| 99 |
FileInfoGCWii m_root; |
| 100 |
|
| 101 |
mutable std::map<u64, u32> m_offset_file_info_cache; |
| 102 |
|
| 103 |
std::unique_ptr<FileInfo> FindFileInfo(std::string_view path, const FileInfo& file_info) const; |
| 104 |
}; |
| 105 |
|
| 106 |
} |