summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2018-01-19 21:45:07 -0500
committerGravatar bunnei2018-01-21 15:39:18 -0500
commit2f71a32363ba062f42938091acdf11962cba932e (patch)
treeaf4cf850934bec6faa47ba74c10b6cb5759e8f3f
parentMerge pull request #129 from Rozelette/master (diff)
downloadyuzu-2f71a32363ba062f42938091acdf11962cba932e.tar.gz
yuzu-2f71a32363ba062f42938091acdf11962cba932e.tar.xz
yuzu-2f71a32363ba062f42938091acdf11962cba932e.zip
file_sys: Repurpose 3DS IVFC code for Switch ROMFS.
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/file_sys/romfs_archive.cpp (renamed from src/core/file_sys/ivfc_archive.cpp)69
-rw-r--r--src/core/file_sys/romfs_archive.h (renamed from src/core/file_sys/ivfc_archive.h)21
3 files changed, 43 insertions, 51 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 7153c4f3f..ec25ec9cf 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -13,10 +13,10 @@ add_library(core STATIC
13 file_sys/disk_archive.h 13 file_sys/disk_archive.h
14 file_sys/errors.h 14 file_sys/errors.h
15 file_sys/file_backend.h 15 file_sys/file_backend.h
16 file_sys/ivfc_archive.cpp
17 file_sys/ivfc_archive.h
18 file_sys/path_parser.cpp 16 file_sys/path_parser.cpp
19 file_sys/path_parser.h 17 file_sys/path_parser.h
18 file_sys/romfs_archive.cpp
19 file_sys/romfs_archive.h
20 file_sys/savedata_archive.cpp 20 file_sys/savedata_archive.cpp
21 file_sys/savedata_archive.h 21 file_sys/savedata_archive.h
22 file_sys/title_metadata.cpp 22 file_sys/title_metadata.cpp
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/romfs_archive.cpp
index b3c3f2c6f..482de2220 100644
--- a/src/core/file_sys/ivfc_archive.cpp
+++ b/src/core/file_sys/romfs_archive.cpp
@@ -1,4 +1,4 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
@@ -6,84 +6,79 @@
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/file_sys/ivfc_archive.h" 9#include "core/file_sys/romfs_archive.h"
10
11////////////////////////////////////////////////////////////////////////////////////////////////////
12// FileSys namespace
13 10
14namespace FileSys { 11namespace FileSys {
15 12
16std::string IVFCArchive::GetName() const { 13std::string ROMFSArchive::GetName() const {
17 return "IVFC"; 14 return "RomFS";
18} 15}
19 16
20ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path, 17ResultVal<std::unique_ptr<FileBackend>> ROMFSArchive::OpenFile(const Path& path,
21 const Mode& mode) const { 18 const Mode& mode) const {
22 return MakeResult<std::unique_ptr<FileBackend>>( 19 return MakeResult<std::unique_ptr<FileBackend>>(
23 std::make_unique<IVFCFile>(romfs_file, data_offset, data_size)); 20 std::make_unique<ROMFSFile>(romfs_file, data_offset, data_size));
24} 21}
25 22
26ResultCode IVFCArchive::DeleteFile(const Path& path) const { 23ResultCode ROMFSArchive::DeleteFile(const Path& path) const {
27 LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive (%s).", 24 LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).",
28 GetName().c_str()); 25 GetName().c_str());
29 // TODO(bunnei): Use correct error code 26 // TODO(bunnei): Use correct error code
30 return ResultCode(-1); 27 return ResultCode(-1);
31} 28}
32 29
33ResultCode IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { 30ResultCode ROMFSArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
34 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).", 31 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).",
35 GetName().c_str()); 32 GetName().c_str());
36 // TODO(wwylele): Use correct error code 33 // TODO(wwylele): Use correct error code
37 return ResultCode(-1); 34 return ResultCode(-1);
38} 35}
39 36
40ResultCode IVFCArchive::DeleteDirectory(const Path& path) const { 37ResultCode ROMFSArchive::DeleteDirectory(const Path& path) const {
41 LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).", 38 LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive (%s).",
42 GetName().c_str()); 39 GetName().c_str());
43 // TODO(wwylele): Use correct error code 40 // TODO(wwylele): Use correct error code
44 return ResultCode(-1); 41 return ResultCode(-1);
45} 42}
46 43
47ResultCode IVFCArchive::DeleteDirectoryRecursively(const Path& path) const { 44ResultCode ROMFSArchive::DeleteDirectoryRecursively(const Path& path) const {
48 LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).", 45 LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive (%s).",
49 GetName().c_str()); 46 GetName().c_str());
50 // TODO(wwylele): Use correct error code 47 // TODO(wwylele): Use correct error code
51 return ResultCode(-1); 48 return ResultCode(-1);
52} 49}
53 50
54ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { 51ResultCode ROMFSArchive::CreateFile(const Path& path, u64 size) const {
55 LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive (%s).", 52 LOG_CRITICAL(Service_FS, "Attempted to create a file in an ROMFS archive (%s).",
56 GetName().c_str()); 53 GetName().c_str());
57 // TODO(bunnei): Use correct error code 54 // TODO(bunnei): Use correct error code
58 return ResultCode(-1); 55 return ResultCode(-1);
59} 56}
60 57
61ResultCode IVFCArchive::CreateDirectory(const Path& path) const { 58ResultCode ROMFSArchive::CreateDirectory(const Path& path) const {
62 LOG_CRITICAL(Service_FS, "Attempted to create a directory in an IVFC archive (%s).", 59 LOG_CRITICAL(Service_FS, "Attempted to create a directory in an ROMFS archive (%s).",
63 GetName().c_str()); 60 GetName().c_str());
64 // TODO(wwylele): Use correct error code 61 // TODO(wwylele): Use correct error code
65 return ResultCode(-1); 62 return ResultCode(-1);
66} 63}
67 64
68ResultCode IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { 65ResultCode ROMFSArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
69 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).", 66 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).",
70 GetName().c_str()); 67 GetName().c_str());
71 // TODO(wwylele): Use correct error code 68 // TODO(wwylele): Use correct error code
72 return ResultCode(-1); 69 return ResultCode(-1);
73} 70}
74 71
75ResultVal<std::unique_ptr<DirectoryBackend>> IVFCArchive::OpenDirectory(const Path& path) const { 72ResultVal<std::unique_ptr<DirectoryBackend>> ROMFSArchive::OpenDirectory(const Path& path) const {
76 return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<IVFCDirectory>()); 73 return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<ROMFSDirectory>());
77} 74}
78 75
79u64 IVFCArchive::GetFreeBytes() const { 76u64 ROMFSArchive::GetFreeBytes() const {
80 LOG_WARNING(Service_FS, "Attempted to get the free space in an IVFC archive"); 77 LOG_WARNING(Service_FS, "Attempted to get the free space in an ROMFS archive");
81 return 0; 78 return 0;
82} 79}
83 80
84//////////////////////////////////////////////////////////////////////////////////////////////////// 81ResultVal<size_t> ROMFSFile::Read(const u64 offset, const size_t length, u8* buffer) const {
85
86ResultVal<size_t> IVFCFile::Read(const u64 offset, const size_t length, u8* buffer) const {
87 LOG_TRACE(Service_FS, "called offset=%llu, length=%zu", offset, length); 82 LOG_TRACE(Service_FS, "called offset=%llu, length=%zu", offset, length);
88 romfs_file->Seek(data_offset + offset, SEEK_SET); 83 romfs_file->Seek(data_offset + offset, SEEK_SET);
89 size_t read_length = (size_t)std::min((u64)length, data_size - offset); 84 size_t read_length = (size_t)std::min((u64)length, data_size - offset);
@@ -91,19 +86,19 @@ ResultVal<size_t> IVFCFile::Read(const u64 offset, const size_t length, u8* buff
91 return MakeResult<size_t>(romfs_file->ReadBytes(buffer, read_length)); 86 return MakeResult<size_t>(romfs_file->ReadBytes(buffer, read_length));
92} 87}
93 88
94ResultVal<size_t> IVFCFile::Write(const u64 offset, const size_t length, const bool flush, 89ResultVal<size_t> ROMFSFile::Write(const u64 offset, const size_t length, const bool flush,
95 const u8* buffer) const { 90 const u8* buffer) const {
96 LOG_ERROR(Service_FS, "Attempted to write to IVFC file"); 91 LOG_ERROR(Service_FS, "Attempted to write to ROMFS file");
97 // TODO(Subv): Find error code 92 // TODO(Subv): Find error code
98 return MakeResult<size_t>(0); 93 return MakeResult<size_t>(0);
99} 94}
100 95
101u64 IVFCFile::GetSize() const { 96u64 ROMFSFile::GetSize() const {
102 return data_size; 97 return data_size;
103} 98}
104 99
105bool IVFCFile::SetSize(const u64 size) const { 100bool ROMFSFile::SetSize(const u64 size) const {
106 LOG_ERROR(Service_FS, "Attempted to set the size of an IVFC file"); 101 LOG_ERROR(Service_FS, "Attempted to set the size of an ROMFS file");
107 return false; 102 return false;
108} 103}
109 104
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/romfs_archive.h
index e6fbdfb1f..2bb13146b 100644
--- a/src/core/file_sys/ivfc_archive.h
+++ b/src/core/file_sys/romfs_archive.h
@@ -1,4 +1,4 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
@@ -15,19 +15,16 @@
15#include "core/file_sys/file_backend.h" 15#include "core/file_sys/file_backend.h"
16#include "core/hle/result.h" 16#include "core/hle/result.h"
17 17
18////////////////////////////////////////////////////////////////////////////////////////////////////
19// FileSys namespace
20
21namespace FileSys { 18namespace FileSys {
22 19
23/** 20/**
24 * Helper which implements an interface to deal with IVFC images used in some archives 21 * Helper which implements an interface to deal with Switch .istorage ROMFS images used in some
25 * This should be subclassed by concrete archive types, which will provide the 22 * archives This should be subclassed by concrete archive types, which will provide the input data
26 * input data (load the raw IVFC archive) and override any required methods 23 * (load the raw ROMFS archive) and override any required methods
27 */ 24 */
28class IVFCArchive : public ArchiveBackend { 25class ROMFSArchive : public ArchiveBackend {
29public: 26public:
30 IVFCArchive(std::shared_ptr<FileUtil::IOFile> file, u64 offset, u64 size) 27 ROMFSArchive(std::shared_ptr<FileUtil::IOFile> file, u64 offset, u64 size)
31 : romfs_file(file), data_offset(offset), data_size(size) {} 28 : romfs_file(file), data_offset(offset), data_size(size) {}
32 29
33 std::string GetName() const override; 30 std::string GetName() const override;
@@ -50,9 +47,9 @@ protected:
50 u64 data_size; 47 u64 data_size;
51}; 48};
52 49
53class IVFCFile : public FileBackend { 50class ROMFSFile : public FileBackend {
54public: 51public:
55 IVFCFile(std::shared_ptr<FileUtil::IOFile> file, u64 offset, u64 size) 52 ROMFSFile(std::shared_ptr<FileUtil::IOFile> file, u64 offset, u64 size)
56 : romfs_file(file), data_offset(offset), data_size(size) {} 53 : romfs_file(file), data_offset(offset), data_size(size) {}
57 54
58 ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override; 55 ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override;
@@ -70,7 +67,7 @@ private:
70 u64 data_size; 67 u64 data_size;
71}; 68};
72 69
73class IVFCDirectory : public DirectoryBackend { 70class ROMFSDirectory : public DirectoryBackend {
74public: 71public:
75 u32 Read(const u32 count, Entry* entries) override { 72 u32 Read(const u32 count, Entry* entries) override {
76 return 0; 73 return 0;