summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-08-18 21:28:17 -0400
committerGravatar Zach Hilman2018-08-18 21:28:23 -0400
commit27da7bc9daf951bce69970881bdbc8719378ca39 (patch)
tree67fb66ecb4ab97f2036712eb5b75216f75e730bf /src/core/file_sys
parentMerge pull request #838 from FearlessTobi/port-3616 (diff)
downloadyuzu-27da7bc9daf951bce69970881bdbc8719378ca39.tar.gz
yuzu-27da7bc9daf951bce69970881bdbc8719378ca39.tar.xz
yuzu-27da7bc9daf951bce69970881bdbc8719378ca39.zip
filesystem: Add support for loading of system archives
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/registered_cache.cpp3
-rw-r--r--src/core/file_sys/romfs_factory.cpp38
-rw-r--r--src/core/file_sys/romfs_factory.h12
3 files changed, 49 insertions, 4 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index d25eeee34..b239c9e48 100644
--- a/src/core/file_sys/registered_cache.cpp
+++ b/src/core/file_sys/registered_cache.cpp
@@ -77,12 +77,13 @@ static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) {
77 case NCAContentType::Control: 77 case NCAContentType::Control:
78 return ContentRecordType::Control; 78 return ContentRecordType::Control;
79 case NCAContentType::Data: 79 case NCAContentType::Data:
80 case static_cast<NCAContentType>(0x05): ///< Seems to be used on some system archives
80 return ContentRecordType::Data; 81 return ContentRecordType::Data;
81 case NCAContentType::Manual: 82 case NCAContentType::Manual:
82 // TODO(DarkLordZach): Peek at NCA contents to differentiate Manual and Legal. 83 // TODO(DarkLordZach): Peek at NCA contents to differentiate Manual and Legal.
83 return ContentRecordType::Manual; 84 return ContentRecordType::Manual;
84 default: 85 default:
85 UNREACHABLE(); 86 UNREACHABLE_MSG("Invalid NCAContentType={:02X}", static_cast<u8>(type));
86 } 87 }
87} 88}
88 89
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index 54fbd3267..7ba4042ca 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -6,7 +6,9 @@
6#include <memory> 6#include <memory>
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9#include "core/core.h"
9#include "core/file_sys/romfs_factory.h" 10#include "core/file_sys/romfs_factory.h"
11#include "core/hle/kernel/process.h"
10 12
11namespace FileSys { 13namespace FileSys {
12 14
@@ -17,9 +19,41 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) {
17 } 19 }
18} 20}
19 21
20ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id) { 22ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
21 // TODO(DarkLordZach): Use title id.
22 return MakeResult<VirtualFile>(file); 23 return MakeResult<VirtualFile>(file);
23} 24}
24 25
26ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) {
27 switch (storage) {
28 case StorageId::NandSystem: {
29 const auto res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type);
30 if (res == nullptr) {
31 // TODO(DarkLordZach): Find the right error code to use here
32 return ResultCode(-1);
33 }
34 const auto romfs = res->GetRomFS();
35 if (romfs == nullptr) {
36 // TODO(DarkLordZach): Find the right error code to use here
37 return ResultCode(-1);
38 }
39 return MakeResult<VirtualFile>(romfs);
40 }
41 case StorageId::NandUser: {
42 const auto res = Service::FileSystem::GetUserNANDContents()->GetEntry(title_id, type);
43 if (res == nullptr) {
44 // TODO(DarkLordZach): Find the right error code to use here
45 return ResultCode(-1);
46 }
47 const auto romfs = res->GetRomFS();
48 if (romfs == nullptr) {
49 // TODO(DarkLordZach): Find the right error code to use here
50 return ResultCode(-1);
51 }
52 return MakeResult<VirtualFile>(romfs);
53 }
54 default:
55 UNIMPLEMENTED_MSG("Unimplmented storage_id={:02X}", static_cast<u8>(storage));
56 }
57}
58
25} // namespace FileSys 59} // namespace FileSys
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h
index c19787cd4..455cd4159 100644
--- a/src/core/file_sys/romfs_factory.h
+++ b/src/core/file_sys/romfs_factory.h
@@ -11,12 +11,22 @@
11 11
12namespace FileSys { 12namespace FileSys {
13 13
14enum class StorageId : u8 {
15 None = 0,
16 Host = 1,
17 GameCard = 2,
18 NandSystem = 3,
19 NandUser = 4,
20 SdCard = 5,
21};
22
14/// File system interface to the RomFS archive 23/// File system interface to the RomFS archive
15class RomFSFactory { 24class RomFSFactory {
16public: 25public:
17 explicit RomFSFactory(Loader::AppLoader& app_loader); 26 explicit RomFSFactory(Loader::AppLoader& app_loader);
18 27
19 ResultVal<VirtualFile> Open(u64 title_id); 28 ResultVal<VirtualFile> OpenCurrentProcess();
29 ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type);
20 30
21private: 31private:
22 VirtualFile file; 32 VirtualFile file;