MCPcopy Create free account
hub / github.com/XorTroll/Goldleaf / PFS0

Method PFS0

Goldleaf/source/fs/fs_PFS0.cpp:26–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace fs {
25
26 PFS0::PFS0(fs::Explorer *exp, const std::string &path) {
27 this->path = path;
28 this->exp = exp;
29 this->ok = false;
30 this->header_size = 0;
31 this->string_table = nullptr;
32
33 this->exp->StartFile(this->path, fs::FileMode::Read);
34 this->exp->ReadFile(this->path, 0, sizeof(this->header), &this->header);
35 if(this->header.magic == Magic) {
36 this->ok = true;
37 const auto string_table_offset = sizeof(Header) + (sizeof(FileEntry) * this->header.file_count);
38 this->string_table = new u8[this->header.string_table_size]();
39 this->header_size = string_table_offset + this->header.string_table_size;
40 this->exp->ReadFile(this->path, string_table_offset, this->header.string_table_size, this->string_table);
41 for(u32 i = 0; i < this->header.file_count; i++) {
42 const auto offset = sizeof(Header) + (i * sizeof(FileEntry));
43 FileEntry ent = {};
44 this->exp->ReadFile(this->path, offset, sizeof(ent), &ent);
45 std::string name;
46 for(u32 j = ent.string_table_offset; j < this->header.string_table_size; j++) {
47 const auto ch = static_cast<char>(this->string_table[j]);
48 if(ch == '\0') {
49 break;
50 }
51 name += ch;
52 }
53 const File file = {
54 .entry = ent,
55 .name = name,
56 };
57 this->files.push_back(file);
58 }
59 }
60 this->exp->EndFile();
61 }
62
63 PFS0::~PFS0() {
64 if(this->string_table != nullptr) {

Callers

nothing calls this directly

Calls 3

StartFileMethod · 0.80
EndFileMethod · 0.80
ReadFileMethod · 0.45

Tested by

no test coverage detected