summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/content_archive.h1
-rw-r--r--src/core/file_sys/nca_metadata.h1
-rw-r--r--src/core/file_sys/registered_cache.cpp3
-rw-r--r--src/core/file_sys/romfs_factory.cpp43
-rw-r--r--src/core/file_sys/romfs_factory.h20
-rw-r--r--src/core/file_sys/sdmc_factory.cpp1
-rw-r--r--src/core/file_sys/sdmc_factory.h1
-rw-r--r--src/core/file_sys/vfs.cpp1
-rw-r--r--src/core/file_sys/vfs.h5
9 files changed, 67 insertions, 9 deletions
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h
index b82e65ad5..4b74c54ec 100644
--- a/src/core/file_sys/content_archive.h
+++ b/src/core/file_sys/content_archive.h
@@ -27,6 +27,7 @@ enum class NCAContentType : u8 {
Control = 2,
Manual = 3,
Data = 4,
+ Data_Unknown5 = 5, ///< Seems to be used on some system archives
};
enum class NCASectionCryptoType : u8 {
diff --git a/src/core/file_sys/nca_metadata.h b/src/core/file_sys/nca_metadata.h
index 88e66d4da..ce05b4c1d 100644
--- a/src/core/file_sys/nca_metadata.h
+++ b/src/core/file_sys/nca_metadata.h
@@ -7,6 +7,7 @@
#include <cstring>
#include <memory>
#include <vector>
+#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/swap.h"
#include "core/file_sys/vfs.h"
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index d25eeee34..e90dc6695 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) {
case NCAContentType::Control:
return ContentRecordType::Control;
case NCAContentType::Data:
+ case NCAContentType::Data_Unknown5:
return ContentRecordType::Data;
case NCAContentType::Manual:
// TODO(DarkLordZach): Peek at NCA contents to differentiate Manual and Legal.
return ContentRecordType::Manual;
default:
- UNREACHABLE();
+ UNREACHABLE_MSG("Invalid NCAContentType={:02X}", static_cast<u8>(type));
}
}
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index 54fbd3267..eb4e6c865 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -6,20 +6,57 @@
#include <memory>
#include "common/common_types.h"
#include "common/logging/log.h"
+#include "core/file_sys/nca_metadata.h"
+#include "core/file_sys/registered_cache.h"
#include "core/file_sys/romfs_factory.h"
+#include "core/hle/kernel/process.h"
+#include "core/hle/service/filesystem/filesystem.h"
+#include "core/loader/loader.h"
namespace FileSys {
RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) {
// Load the RomFS from the app
- if (Loader::ResultStatus::Success != app_loader.ReadRomFS(file)) {
+ if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) {
LOG_ERROR(Service_FS, "Unable to read RomFS!");
}
}
-ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id) {
- // TODO(DarkLordZach): Use title id.
+ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
return MakeResult<VirtualFile>(file);
}
+ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) {
+ switch (storage) {
+ case StorageId::NandSystem: {
+ const auto res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type);
+ if (res == nullptr) {
+ // TODO(DarkLordZach): Find the right error code to use here
+ return ResultCode(-1);
+ }
+ const auto romfs = res->GetRomFS();
+ if (romfs == nullptr) {
+ // TODO(DarkLordZach): Find the right error code to use here
+ return ResultCode(-1);
+ }
+ return MakeResult<VirtualFile>(romfs);
+ }
+ case StorageId::NandUser: {
+ const auto res = Service::FileSystem::GetUserNANDContents()->GetEntry(title_id, type);
+ if (res == nullptr) {
+ // TODO(DarkLordZach): Find the right error code to use here
+ return ResultCode(-1);
+ }
+ const auto romfs = res->GetRomFS();
+ if (romfs == nullptr) {
+ // TODO(DarkLordZach): Find the right error code to use here
+ return ResultCode(-1);
+ }
+ return MakeResult<VirtualFile>(romfs);
+ }
+ default:
+ UNIMPLEMENTED_MSG("Unimplemented storage_id={:02X}", static_cast<u8>(storage));
+ }
+}
+
} // namespace FileSys
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h
index c19787cd4..f38ddc4f7 100644
--- a/src/core/file_sys/romfs_factory.h
+++ b/src/core/file_sys/romfs_factory.h
@@ -6,17 +6,33 @@
#include <memory>
#include "common/common_types.h"
+#include "core/file_sys/vfs.h"
#include "core/hle/result.h"
-#include "core/loader/loader.h"
+
+namespace Loader {
+class AppLoader;
+} // namespace Loader
namespace FileSys {
+enum class ContentRecordType : u8;
+
+enum class StorageId : u8 {
+ None = 0,
+ Host = 1,
+ GameCard = 2,
+ NandSystem = 3,
+ NandUser = 4,
+ SdCard = 5,
+};
+
/// File system interface to the RomFS archive
class RomFSFactory {
public:
explicit RomFSFactory(Loader::AppLoader& app_loader);
- ResultVal<VirtualFile> Open(u64 title_id);
+ ResultVal<VirtualFile> OpenCurrentProcess();
+ ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type);
private:
VirtualFile file;
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp
index c1edfcef3..d1acf379f 100644
--- a/src/core/file_sys/sdmc_factory.cpp
+++ b/src/core/file_sys/sdmc_factory.cpp
@@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include <memory>
-#include "core/core.h"
#include "core/file_sys/sdmc_factory.h"
namespace FileSys {
diff --git a/src/core/file_sys/sdmc_factory.h b/src/core/file_sys/sdmc_factory.h
index 9f0c75e84..245060690 100644
--- a/src/core/file_sys/sdmc_factory.h
+++ b/src/core/file_sys/sdmc_factory.h
@@ -4,6 +4,7 @@
#pragma once
+#include "core/file_sys/vfs.h"
#include "core/hle/result.h"
namespace FileSys {
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp
index a5ec50b1a..b915b4c11 100644
--- a/src/core/file_sys/vfs.cpp
+++ b/src/core/file_sys/vfs.cpp
@@ -8,6 +8,7 @@
#include "common/common_paths.h"
#include "common/file_util.h"
#include "common/logging/backend.h"
+#include "core/file_sys/mode.h"
#include "core/file_sys/vfs.h"
namespace FileSys {
diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h
index 78a63c59b..22db08b59 100644
--- a/src/core/file_sys/vfs.h
+++ b/src/core/file_sys/vfs.h
@@ -9,9 +9,8 @@
#include <string_view>
#include <type_traits>
#include <vector>
-#include "boost/optional.hpp"
+#include <boost/optional.hpp>
#include "common/common_types.h"
-#include "core/file_sys/mode.h"
namespace FileSys {
@@ -19,6 +18,8 @@ class VfsDirectory;
class VfsFile;
class VfsFilesystem;
+enum class Mode : u32;
+
// Convenience typedefs to use Vfs* interfaces
using VirtualFilesystem = std::shared_ptr<VfsFilesystem>;
using VirtualDir = std::shared_ptr<VfsDirectory>;