libnedit
Lightweight C++ library for Nintendo DS(i) formats
Loading...
Searching...
No Matches
fmt_Utility.hpp
1
2#pragma once
3#include <ntr/fmt/fmt_Common.hpp>
4#include <ntr/fmt/nfs/nfs_NitroFs.hpp>
5
6namespace ntr::fmt {
7
9
10 struct Header {
11 u32 fnt_offset;
12 u32 fnt_size;
13 u32 fat_offset;
14 u32 fat_size;
15 };
16
17 Header header;
18
19 Utility() {}
20 Utility(const Utility&) = delete;
21
22 size_t GetBaseOffset() override {
23 // Offset after FAT and FNT (and alignment)
24 return util::AlignUp(this->GetFatEntriesOffset() + this->header.fat_size, 0x20);
25 }
26
27 size_t GetFatEntriesOffset() override {
28 return this->header.fat_offset;
29 }
30
31 size_t GetFatEntryCount() override {
32 return this->header.fat_size / sizeof(nfs::FileAllocationTableEntry);
33 }
34
35 Result OnFileSystemWrite(fs::BinaryFile &w_bf, const ssize_t size_diff) override {
36 // TODO
37 NTR_R_SUCCEED();
38 }
39
40 Result ValidateImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
41 Result ReadImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
42 };
43
44 using UtilityFileHandle = nfs::NitroFsFileHandle<Utility>;
45
46}
Definition fmt_Utility.hpp:10
Definition fmt_Utility.hpp:8
Definition nfs_NitroFs.hpp:43