summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando S2023-12-19 16:14:29 +0100
committerGravatar GitHub2023-12-19 16:14:29 +0100
commitb14547b8b6335536a5773bb67521f1983e1a8ec5 (patch)
treefa6a3a6ab6e916236ba825534b0bf09225a05a1b /src
parentMerge pull request #12391 from yuzu-emu/revert-12344-its-free-real-estate (diff)
parentfs: implement OpenDirectoryMode (diff)
downloadyuzu-b14547b8b6335536a5773bb67521f1983e1a8ec5.tar.gz
yuzu-b14547b8b6335536a5773bb67521f1983e1a8ec5.tar.xz
yuzu-b14547b8b6335536a5773bb67521f1983e1a8ec5.zip
Merge pull request #12392 from liamwhite/mode
fs: implement OpenDirectoryMode
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/filesystem/filesystem.h7
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp18
2 files changed, 17 insertions, 8 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h
index e7e7c4c28..276d264e1 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -54,6 +54,13 @@ enum class ImageDirectoryId : u32 {
54 SdCard, 54 SdCard,
55}; 55};
56 56
57enum class OpenDirectoryMode : u64 {
58 Directory = (1 << 0),
59 File = (1 << 1),
60 All = Directory | File
61};
62DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode);
63
57class FileSystemController { 64class FileSystemController {
58public: 65public:
59 explicit FileSystemController(Core::System& system_); 66 explicit FileSystemController(Core::System& system_);
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index b1310d6e4..82ecc1b90 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -259,7 +259,7 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec
259 259
260class IDirectory final : public ServiceFramework<IDirectory> { 260class IDirectory final : public ServiceFramework<IDirectory> {
261public: 261public:
262 explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_) 262 explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_, OpenDirectoryMode mode)
263 : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) { 263 : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) {
264 static const FunctionInfo functions[] = { 264 static const FunctionInfo functions[] = {
265 {0, &IDirectory::Read, "Read"}, 265 {0, &IDirectory::Read, "Read"},
@@ -269,8 +269,12 @@ public:
269 269
270 // TODO(DarkLordZach): Verify that this is the correct behavior. 270 // TODO(DarkLordZach): Verify that this is the correct behavior.
271 // Build entry index now to save time later. 271 // Build entry index now to save time later.
272 BuildEntryIndex(entries, backend->GetFiles(), FileSys::EntryType::File); 272 if (True(mode & OpenDirectoryMode::Directory)) {
273 BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::EntryType::Directory); 273 BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::EntryType::Directory);
274 }
275 if (True(mode & OpenDirectoryMode::File)) {
276 BuildEntryIndex(entries, backend->GetFiles(), FileSys::EntryType::File);
277 }
274 } 278 }
275 279
276private: 280private:
@@ -446,11 +450,9 @@ public:
446 450
447 const auto file_buffer = ctx.ReadBuffer(); 451 const auto file_buffer = ctx.ReadBuffer();
448 const std::string name = Common::StringFromBuffer(file_buffer); 452 const std::string name = Common::StringFromBuffer(file_buffer);
453 const auto mode = rp.PopRaw<OpenDirectoryMode>();
449 454
450 // TODO(Subv): Implement this filter. 455 LOG_DEBUG(Service_FS, "called. directory={}, mode={}", name, mode);
451 const u32 filter_flags = rp.Pop<u32>();
452
453 LOG_DEBUG(Service_FS, "called. directory={}, filter={}", name, filter_flags);
454 456
455 FileSys::VirtualDir vfs_dir{}; 457 FileSys::VirtualDir vfs_dir{};
456 auto result = backend.OpenDirectory(&vfs_dir, name); 458 auto result = backend.OpenDirectory(&vfs_dir, name);
@@ -460,7 +462,7 @@ public:
460 return; 462 return;
461 } 463 }
462 464
463 auto directory = std::make_shared<IDirectory>(system, vfs_dir); 465 auto directory = std::make_shared<IDirectory>(system, vfs_dir, mode);
464 466
465 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 467 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
466 rb.Push(ResultSuccess); 468 rb.Push(ResultSuccess);