diff options
| author | 2018-07-18 21:07:11 -0400 | |
|---|---|---|
| committer | 2018-07-18 18:07:11 -0700 | |
| commit | 29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef (patch) | |
| tree | 3202e2ce55ab6387a4ca366a509eccdd963434c3 /src/core/file_sys/filesystem.cpp | |
| parent | Merge pull request #683 from DarkLordZach/touch (diff) | |
| download | yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.gz yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.xz yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.zip | |
Virtual Filesystem 2: Electric Boogaloo (#676)
* Virtual Filesystem
* Fix delete bug and documentate
* Review fixes + other stuff
* Fix puyo regression
Diffstat (limited to 'src/core/file_sys/filesystem.cpp')
| -rw-r--r-- | src/core/file_sys/filesystem.cpp | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/src/core/file_sys/filesystem.cpp b/src/core/file_sys/filesystem.cpp deleted file mode 100644 index 82fdb3c46..000000000 --- a/src/core/file_sys/filesystem.cpp +++ /dev/null | |||
| @@ -1,122 +0,0 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstddef> | ||
| 6 | #include <iomanip> | ||
| 7 | #include <sstream> | ||
| 8 | #include "common/logging/log.h" | ||
| 9 | #include "common/string_util.h" | ||
| 10 | #include "core/file_sys/filesystem.h" | ||
| 11 | #include "core/memory.h" | ||
| 12 | |||
| 13 | namespace FileSys { | ||
| 14 | |||
| 15 | Path::Path(LowPathType type, u32 size, u32 pointer) : type(type) { | ||
| 16 | switch (type) { | ||
| 17 | case Binary: { | ||
| 18 | binary.resize(size); | ||
| 19 | Memory::ReadBlock(pointer, binary.data(), binary.size()); | ||
| 20 | break; | ||
| 21 | } | ||
| 22 | |||
| 23 | case Char: { | ||
| 24 | string.resize(size - 1); // Data is always null-terminated. | ||
| 25 | Memory::ReadBlock(pointer, &string[0], string.size()); | ||
| 26 | break; | ||
| 27 | } | ||
| 28 | |||
| 29 | case Wchar: { | ||
| 30 | u16str.resize(size / 2 - 1); // Data is always null-terminated. | ||
| 31 | Memory::ReadBlock(pointer, &u16str[0], u16str.size() * sizeof(char16_t)); | ||
| 32 | break; | ||
| 33 | } | ||
| 34 | |||
| 35 | default: | ||
| 36 | break; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | std::string Path::DebugStr() const { | ||
| 41 | switch (GetType()) { | ||
| 42 | case Invalid: | ||
| 43 | default: | ||
| 44 | return "[Invalid]"; | ||
| 45 | case Empty: | ||
| 46 | return "[Empty]"; | ||
| 47 | case Binary: { | ||
| 48 | std::stringstream res; | ||
| 49 | res << "[Binary: "; | ||
| 50 | for (unsigned byte : binary) | ||
| 51 | res << std::hex << std::setw(2) << std::setfill('0') << byte; | ||
| 52 | res << ']'; | ||
| 53 | return res.str(); | ||
| 54 | } | ||
| 55 | case Char: | ||
| 56 | return "[Char: " + AsString() + ']'; | ||
| 57 | case Wchar: | ||
| 58 | return "[Wchar: " + AsString() + ']'; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | std::string Path::AsString() const { | ||
| 63 | switch (GetType()) { | ||
| 64 | case Char: | ||
| 65 | return string; | ||
| 66 | case Wchar: | ||
| 67 | return Common::UTF16ToUTF8(u16str); | ||
| 68 | case Empty: | ||
| 69 | return {}; | ||
| 70 | case Invalid: | ||
| 71 | case Binary: | ||
| 72 | default: | ||
| 73 | // TODO(yuriks): Add assert | ||
| 74 | LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!"); | ||
| 75 | return {}; | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | std::u16string Path::AsU16Str() const { | ||
| 80 | switch (GetType()) { | ||
| 81 | case Char: | ||
| 82 | return Common::UTF8ToUTF16(string); | ||
| 83 | case Wchar: | ||
| 84 | return u16str; | ||
| 85 | case Empty: | ||
| 86 | return {}; | ||
| 87 | case Invalid: | ||
| 88 | case Binary: | ||
| 89 | // TODO(yuriks): Add assert | ||
| 90 | LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!"); | ||
| 91 | return {}; | ||
| 92 | } | ||
| 93 | |||
| 94 | UNREACHABLE(); | ||
| 95 | } | ||
| 96 | |||
| 97 | std::vector<u8> Path::AsBinary() const { | ||
| 98 | switch (GetType()) { | ||
| 99 | case Binary: | ||
| 100 | return binary; | ||
| 101 | case Char: | ||
| 102 | return std::vector<u8>(string.begin(), string.end()); | ||
| 103 | case Wchar: { | ||
| 104 | // use two u8 for each character of u16str | ||
| 105 | std::vector<u8> to_return(u16str.size() * 2); | ||
| 106 | for (size_t i = 0; i < u16str.size(); ++i) { | ||
| 107 | u16 tmp_char = u16str.at(i); | ||
| 108 | to_return[i * 2] = (tmp_char & 0xFF00) >> 8; | ||
| 109 | to_return[i * 2 + 1] = (tmp_char & 0x00FF); | ||
| 110 | } | ||
| 111 | return to_return; | ||
| 112 | } | ||
| 113 | case Empty: | ||
| 114 | return {}; | ||
| 115 | case Invalid: | ||
| 116 | default: | ||
| 117 | // TODO(yuriks): Add assert | ||
| 118 | LOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!"); | ||
| 119 | return {}; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | } // namespace FileSys | ||