libeditwl
Lightweight C++ library for Nintendo DS(i) formats
Loading...
Searching...
No Matches
fmt_Utility.hpp
1
2#pragma once
3#include <twl/fmt/fmt_Common.hpp>
4#include <twl/fmt/nfs/nfs_NitroFs.hpp>
5
6namespace twl::fmt {
7
8 struct Utility : public fs::FileFormat, public nfs::NitroFileSystemFormat {
9
10 struct Header {
11 u32 fnt_offset;
12 u32 fnt_size;
13 u32 fat_offset;
14 u32 fat_size;
15 };
16
17 static constexpr size_t SectionAlignment = 0x20;
18
19 Header header;
20
21 Utility() {}
22 Utility(const Utility&) = delete;
23 Utility(Utility&&) = default;
24
25 size_t GetBaseOffset() override {
26 // Offset after FAT and FNT (and alignment)
27 return util::AlignUp(this->GetFatEntriesOffset() + this->header.fat_size, 0x20);
28 }
29
30 size_t GetFatEntriesOffset() const override {
31 return this->header.fat_offset;
32 }
33
34 size_t GetFatEntryCount() const override {
35 return this->header.fat_size / sizeof(nfs::FileAllocationTableEntry);
36 }
37
38 Result OnFileSystemWrite(fs::BinaryFile &w_bf, const ssize_t size_diff) override {
39 // TODO
40 NTR_R_SUCCEED();
41 }
42
43 Result ReadValidateFrom(fs::File &rf) override;
44 Result ReadAllFrom(fs::File &rf) override;
45 Result WriteTo(fs::File &wf) override;
46 };
47
48}
Definition nfs_NitroFs.hpp:100
Definition fs_FileFormat.hpp:7
Definition fmt_Utility.hpp:10
Definition fmt_Utility.hpp:8