mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
Filesystem stuff
This commit is contained in:
parent
5992a58351
commit
272cdefca1
13 changed files with 222 additions and 32 deletions
61
include/fs/archive_base.hpp
Normal file
61
include/fs/archive_base.hpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#pragma once
|
||||
#include <optional>
|
||||
#include "helpers.hpp"
|
||||
#include "memory.hpp"
|
||||
|
||||
namespace PathType {
|
||||
enum : u32 {
|
||||
Invalid = 0,
|
||||
Empty = 1,
|
||||
Binary = 2,
|
||||
ASCII = 3,
|
||||
UTF8 = 4,
|
||||
};
|
||||
}
|
||||
|
||||
namespace ArchiveID {
|
||||
enum : u32 {
|
||||
SelfNCCH = 3,
|
||||
SaveData = 4,
|
||||
ExtSaveData = 6,
|
||||
SharedExtSaveData = 7,
|
||||
SystemSaveData = 8,
|
||||
SDMC = 9,
|
||||
SDMCWriteOnly = 0xA
|
||||
};
|
||||
|
||||
static const char* toString(u32 id) {
|
||||
switch (id) {
|
||||
case SelfNCCH: return "SelfNCCH";
|
||||
case SaveData: return "SaveData";
|
||||
case ExtSaveData: return "ExtSaveData";
|
||||
case SharedExtSaveData: return "SharedExtSaveData";
|
||||
case SystemSaveData: return "SystemSaveData";
|
||||
case SDMC: return "SDMC";
|
||||
case SDMCWriteOnly: return "SDMC (Write-only)";
|
||||
default: return "Unknown archive";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct FSPath {
|
||||
u32 type;
|
||||
u32 size;
|
||||
u32 pointer; // Pointer to the actual path data
|
||||
};
|
||||
|
||||
class ArchiveBase {
|
||||
protected:
|
||||
using Result = u32;
|
||||
using Handle = u32;
|
||||
Memory& mem;
|
||||
|
||||
public:
|
||||
virtual const char* name() = 0;
|
||||
virtual u64 getFreeBytes() = 0;
|
||||
virtual bool openFile(const FSPath& path) = 0;
|
||||
|
||||
virtual ArchiveBase* openArchive(FSPath& path) = 0;
|
||||
|
||||
ArchiveBase(Memory& mem) : mem(mem) {}
|
||||
};
|
28
include/fs/archive_ncch.hpp
Normal file
28
include/fs/archive_ncch.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "archive_base.hpp"
|
||||
|
||||
class SelfNCCHArchive : public ArchiveBase {
|
||||
|
||||
public:
|
||||
SelfNCCHArchive(Memory& mem) : ArchiveBase(mem) {}
|
||||
|
||||
u64 getFreeBytes() override { return 0; }
|
||||
const char* name() override { return "SelfNCCH"; }
|
||||
|
||||
bool openFile(const FSPath& path) override {
|
||||
if (path.type != PathType::Binary) {
|
||||
printf("Invalid SelfNCCH path type");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ArchiveBase* openArchive(FSPath& path) override {
|
||||
if (path.type != PathType::Empty) {
|
||||
printf("Invalid path type for SelfNCCH archive: %d\n", path.type);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue