FS: convert to service framework
This commit is contained in:
parent
e8c95a9a41
commit
71fac7bd72
7 changed files with 916 additions and 811 deletions
|
@ -12,23 +12,22 @@
|
|||
|
||||
namespace FileSys {
|
||||
|
||||
Path::Path(LowPathType type, u32 size, u32 pointer) : type(type) {
|
||||
Path::Path(LowPathType type, const std::vector<u8>& data) : type(type) {
|
||||
switch (type) {
|
||||
case LowPathType::Binary: {
|
||||
binary.resize(size);
|
||||
Memory::ReadBlock(pointer, binary.data(), binary.size());
|
||||
binary = data;
|
||||
break;
|
||||
}
|
||||
|
||||
case LowPathType::Char: {
|
||||
string.resize(size - 1); // Data is always null-terminated.
|
||||
Memory::ReadBlock(pointer, &string[0], string.size());
|
||||
string.resize(data.size() - 1); // Data is always null-terminated.
|
||||
std::memcpy(string.data(), data.data(), string.size());
|
||||
break;
|
||||
}
|
||||
|
||||
case LowPathType::Wchar: {
|
||||
u16str.resize(size / 2 - 1); // Data is always null-terminated.
|
||||
Memory::ReadBlock(pointer, &u16str[0], u16str.size() * sizeof(char16_t));
|
||||
u16str.resize(data.size() / 2 - 1); // Data is always null-terminated.
|
||||
std::memcpy(u16str.data(), data.data(), u16str.size() * sizeof(char16_t));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
Path() : type(LowPathType::Invalid) {}
|
||||
Path(const char* path) : type(LowPathType::Char), string(path) {}
|
||||
Path(std::vector<u8> binary_data) : type(LowPathType::Binary), binary(std::move(binary_data)) {}
|
||||
Path(LowPathType type, u32 size, u32 pointer);
|
||||
Path(LowPathType type, const std::vector<u8>& data);
|
||||
|
||||
LowPathType GetType() const {
|
||||
return type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue