summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Ameer2020-07-14 13:04:02 -0400
committerGravatar Ameer2020-07-14 13:04:02 -0400
commit93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3 (patch)
treec4ab9e3acff296733b00effd85371bf04db6491f /src/core/file_sys
parentBreak out of scan loop if can't find adapter on first run (diff)
parentMerge pull request #4294 from MerryMage/cpu-opt-settings (diff)
downloadyuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.tar.gz
yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.tar.xz
yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.zip
Rebase to master
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/bis_factory.cpp23
-rw-r--r--src/core/file_sys/sdmc_factory.cpp4
-rw-r--r--src/core/file_sys/vfs_real.cpp27
3 files changed, 33 insertions, 21 deletions
diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp
index 8935a62c3..285277ef8 100644
--- a/src/core/file_sys/bis_factory.cpp
+++ b/src/core/file_sys/bis_factory.cpp
@@ -12,6 +12,10 @@
12 12
13namespace FileSys { 13namespace FileSys {
14 14
15constexpr u64 NAND_USER_SIZE = 0x680000000; // 26624 MiB
16constexpr u64 NAND_SYSTEM_SIZE = 0xA0000000; // 2560 MiB
17constexpr u64 NAND_TOTAL_SIZE = 0x747C00000; // 29820 MiB
18
15BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_, VirtualDir dump_root_) 19BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_, VirtualDir dump_root_)
16 : nand_root(std::move(nand_root_)), load_root(std::move(load_root_)), 20 : nand_root(std::move(nand_root_)), load_root(std::move(load_root_)),
17 dump_root(std::move(dump_root_)), 21 dump_root(std::move(dump_root_)),
@@ -110,30 +114,29 @@ VirtualDir BISFactory::GetImageDirectory() const {
110 114
111u64 BISFactory::GetSystemNANDFreeSpace() const { 115u64 BISFactory::GetSystemNANDFreeSpace() const {
112 const auto sys_dir = GetOrCreateDirectoryRelative(nand_root, "/system"); 116 const auto sys_dir = GetOrCreateDirectoryRelative(nand_root, "/system");
113 if (sys_dir == nullptr) 117 if (sys_dir == nullptr) {
114 return 0; 118 return GetSystemNANDTotalSpace();
119 }
115 120
116 return GetSystemNANDTotalSpace() - sys_dir->GetSize(); 121 return GetSystemNANDTotalSpace() - sys_dir->GetSize();
117} 122}
118 123
119u64 BISFactory::GetSystemNANDTotalSpace() const { 124u64 BISFactory::GetSystemNANDTotalSpace() const {
120 return static_cast<u64>(Settings::values.nand_system_size); 125 return NAND_SYSTEM_SIZE;
121} 126}
122 127
123u64 BISFactory::GetUserNANDFreeSpace() const { 128u64 BISFactory::GetUserNANDFreeSpace() const {
124 const auto usr_dir = GetOrCreateDirectoryRelative(nand_root, "/user"); 129 // For some reason games such as BioShock 1 checks whether this is exactly 0x680000000 bytes.
125 if (usr_dir == nullptr) 130 // Set the free space to be 1 MiB less than the total as a workaround to this issue.
126 return 0; 131 return GetUserNANDTotalSpace() - 0x100000;
127
128 return GetUserNANDTotalSpace() - usr_dir->GetSize();
129} 132}
130 133
131u64 BISFactory::GetUserNANDTotalSpace() const { 134u64 BISFactory::GetUserNANDTotalSpace() const {
132 return static_cast<u64>(Settings::values.nand_user_size); 135 return NAND_USER_SIZE;
133} 136}
134 137
135u64 BISFactory::GetFullNANDTotalSpace() const { 138u64 BISFactory::GetFullNANDTotalSpace() const {
136 return static_cast<u64>(Settings::values.nand_total_size); 139 return NAND_TOTAL_SIZE;
137} 140}
138 141
139VirtualDir BISFactory::GetBCATDirectory(u64 title_id) const { 142VirtualDir BISFactory::GetBCATDirectory(u64 title_id) const {
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp
index 5113a1ca6..6f732e4d8 100644
--- a/src/core/file_sys/sdmc_factory.cpp
+++ b/src/core/file_sys/sdmc_factory.cpp
@@ -10,6 +10,8 @@
10 10
11namespace FileSys { 11namespace FileSys {
12 12
13constexpr u64 SDMC_TOTAL_SIZE = 0x10000000000; // 1 TiB
14
13SDMCFactory::SDMCFactory(VirtualDir dir_) 15SDMCFactory::SDMCFactory(VirtualDir dir_)
14 : dir(std::move(dir_)), contents(std::make_unique<RegisteredCache>( 16 : dir(std::move(dir_)), contents(std::make_unique<RegisteredCache>(
15 GetOrCreateDirectoryRelative(dir, "/Nintendo/Contents/registered"), 17 GetOrCreateDirectoryRelative(dir, "/Nintendo/Contents/registered"),
@@ -46,7 +48,7 @@ u64 SDMCFactory::GetSDMCFreeSpace() const {
46} 48}
47 49
48u64 SDMCFactory::GetSDMCTotalSpace() const { 50u64 SDMCFactory::GetSDMCTotalSpace() const {
49 return static_cast<u64>(Settings::values.sdmc_size); 51 return SDMC_TOTAL_SIZE;
50} 52}
51 53
52} // namespace FileSys 54} // namespace FileSys
diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp
index e21300a7c..96ce5957c 100644
--- a/src/core/file_sys/vfs_real.cpp
+++ b/src/core/file_sys/vfs_real.cpp
@@ -112,19 +112,26 @@ VirtualFile RealVfsFilesystem::MoveFile(std::string_view old_path_, std::string_
112 const auto new_path = 112 const auto new_path =
113 FileUtil::SanitizePath(new_path_, FileUtil::DirectorySeparator::PlatformDefault); 113 FileUtil::SanitizePath(new_path_, FileUtil::DirectorySeparator::PlatformDefault);
114 114
115 if (!FileUtil::Exists(old_path) || FileUtil::Exists(new_path) ||
116 FileUtil::IsDirectory(old_path) || !FileUtil::Rename(old_path, new_path))
117 return nullptr;
118
119 if (cache.find(old_path) != cache.end()) { 115 if (cache.find(old_path) != cache.end()) {
120 auto cached = cache[old_path]; 116 auto file = cache[old_path].lock();
121 if (!cached.expired()) { 117
122 auto file = cached.lock(); 118 if (!cache[old_path].expired()) {
123 file->Open(new_path, "r+b"); 119 file->Close();
124 cache.erase(old_path); 120 }
125 cache[new_path] = file; 121
122 if (!FileUtil::Exists(old_path) || FileUtil::Exists(new_path) ||
123 FileUtil::IsDirectory(old_path) || !FileUtil::Rename(old_path, new_path)) {
124 return nullptr;
126 } 125 }
126
127 cache.erase(old_path);
128 file->Open(new_path, "r+b");
129 cache[new_path] = file;
130 } else {
131 UNREACHABLE();
132 return nullptr;
127 } 133 }
134
128 return OpenFile(new_path, Mode::ReadWrite); 135 return OpenFile(new_path, Mode::ReadWrite);
129} 136}
130 137