summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-04-16 14:32:18 -0400
committerGravatar Zach Hilman2019-09-21 16:43:10 -0400
commit43af31836ebe923f0bd34d85b74788e78d04b4e2 (patch)
tree84b0e1b488a80ef04181ff0892a566da72f1d6a9 /src
parentsdmc_factory: Add SD Card size getters (diff)
downloadyuzu-43af31836ebe923f0bd34d85b74788e78d04b4e2.tar.gz
yuzu-43af31836ebe923f0bd34d85b74788e78d04b4e2.tar.xz
yuzu-43af31836ebe923f0bd34d85b74788e78d04b4e2.zip
filesystem: Pass Size Getter functions to IFileSystem for sizes
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp12
-rw-r--r--src/core/hle/service/filesystem/filesystem.h6
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp33
3 files changed, 31 insertions, 20 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index adc1917aa..d8debf612 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -29,11 +29,6 @@
29 29
30namespace Service::FileSystem { 30namespace Service::FileSystem {
31 31
32// Size of emulated sd card free space, reported in bytes.
33// Just using 32GB because thats reasonable
34// TODO(DarkLordZach): Eventually make this configurable in settings.
35constexpr u64 EMULATED_SD_REPORTED_SIZE = 32000000000;
36
37// A default size for normal/journal save data size if application control metadata cannot be found. 32// A default size for normal/journal save data size if application control metadata cannot be found.
38// This should be large enough to satisfy even the most extreme requirements (~4.2GB) 33// This should be large enough to satisfy even the most extreme requirements (~4.2GB)
39constexpr u64 SUFFICIENT_SAVE_DATA_SIZE = 0xF0000000; 34constexpr u64 SUFFICIENT_SAVE_DATA_SIZE = 0xF0000000;
@@ -227,13 +222,6 @@ ResultVal<FileSys::VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const s
227 return MakeResult(dir); 222 return MakeResult(dir);
228} 223}
229 224
230u64 VfsDirectoryServiceWrapper::GetFreeSpaceSize() const {
231 if (backing->IsWritable())
232 return EMULATED_SD_REPORTED_SIZE;
233
234 return 0;
235}
236
237ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType( 225ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType(
238 const std::string& path_) const { 226 const std::string& path_) const {
239 std::string path(FileUtil::SanitizePath(path_)); 227 std::string path(FileUtil::SanitizePath(path_));
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h
index aa4e437ac..2eb3a641d 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -216,12 +216,6 @@ public:
216 ResultVal<FileSys::VirtualDir> OpenDirectory(const std::string& path); 216 ResultVal<FileSys::VirtualDir> OpenDirectory(const std::string& path);
217 217
218 /** 218 /**
219 * Get the free space
220 * @return The number of free bytes in the archive
221 */
222 u64 GetFreeSpaceSize() const;
223
224 /**
225 * Get the type of the specified path 219 * Get the type of the specified path
226 * @return The type of the specified path or error code 220 * @return The type of the specified path or error code
227 */ 221 */
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index d3cd46a9b..85f8e4a63 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -30,6 +30,18 @@
30 30
31namespace Service::FileSystem { 31namespace Service::FileSystem {
32 32
33struct SizeGetter {
34 std::function<u64()> free;
35 std::function<u64()> total;
36
37 static SizeGetter FromStorageId(const FileSystemController& fsc, FileSys::StorageId id) {
38 return {
39 [&fsc, id] { return fsc.GetFreeSpaceSize(id); },
40 [&fsc, id] { return fsc.GetTotalSpaceSize(id); },
41 };
42 }
43};
44
33enum class FileSystemType : u8 { 45enum class FileSystemType : u8 {
34 Invalid0 = 0, 46 Invalid0 = 0,
35 Invalid1 = 1, 47 Invalid1 = 1,
@@ -289,8 +301,8 @@ private:
289 301
290class IFileSystem final : public ServiceFramework<IFileSystem> { 302class IFileSystem final : public ServiceFramework<IFileSystem> {
291public: 303public:
292 explicit IFileSystem(FileSys::VirtualDir backend) 304 explicit IFileSystem(FileSys::VirtualDir backend, SizeGetter size)
293 : ServiceFramework("IFileSystem"), backend(std::move(backend)) { 305 : ServiceFramework("IFileSystem"), backend(std::move(backend)), size(std::move(size)) {
294 static const FunctionInfo functions[] = { 306 static const FunctionInfo functions[] = {
295 {0, &IFileSystem::CreateFile, "CreateFile"}, 307 {0, &IFileSystem::CreateFile, "CreateFile"},
296 {1, &IFileSystem::DeleteFile, "DeleteFile"}, 308 {1, &IFileSystem::DeleteFile, "DeleteFile"},
@@ -467,8 +479,25 @@ public:
467 rb.Push(RESULT_SUCCESS); 479 rb.Push(RESULT_SUCCESS);
468 } 480 }
469 481
482 void GetFreeSpaceSize(Kernel::HLERequestContext& ctx) {
483 LOG_DEBUG(Service_FS, "called");
484
485 IPC::ResponseBuilder rb{ctx, 4};
486 rb.Push(RESULT_SUCCESS);
487 rb.Push(size.free());
488 }
489
490 void GetTotalSpaceSize(Kernel::HLERequestContext& ctx) {
491 LOG_DEBUG(Service_FS, "called");
492
493 IPC::ResponseBuilder rb{ctx, 4};
494 rb.Push(RESULT_SUCCESS);
495 rb.Push(size.total());
496 }
497
470private: 498private:
471 VfsDirectoryServiceWrapper backend; 499 VfsDirectoryServiceWrapper backend;
500 SizeGetter size;
472}; 501};
473 502
474class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> { 503class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> {