mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 10:50:06 +00:00
Merge pull request #12392 from liamwhite/mode
fs: implement OpenDirectoryMode
This commit is contained in:
commit
b14547b8b6
@ -54,6 +54,13 @@ enum class ImageDirectoryId : u32 {
|
|||||||
SdCard,
|
SdCard,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class OpenDirectoryMode : u64 {
|
||||||
|
Directory = (1 << 0),
|
||||||
|
File = (1 << 1),
|
||||||
|
All = Directory | File
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode);
|
||||||
|
|
||||||
class FileSystemController {
|
class FileSystemController {
|
||||||
public:
|
public:
|
||||||
explicit FileSystemController(Core::System& system_);
|
explicit FileSystemController(Core::System& system_);
|
||||||
|
@ -259,7 +259,7 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec
|
|||||||
|
|
||||||
class IDirectory final : public ServiceFramework<IDirectory> {
|
class IDirectory final : public ServiceFramework<IDirectory> {
|
||||||
public:
|
public:
|
||||||
explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_)
|
explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_, OpenDirectoryMode mode)
|
||||||
: ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) {
|
: ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IDirectory::Read, "Read"},
|
{0, &IDirectory::Read, "Read"},
|
||||||
@ -269,9 +269,13 @@ public:
|
|||||||
|
|
||||||
// TODO(DarkLordZach): Verify that this is the correct behavior.
|
// TODO(DarkLordZach): Verify that this is the correct behavior.
|
||||||
// Build entry index now to save time later.
|
// Build entry index now to save time later.
|
||||||
BuildEntryIndex(entries, backend->GetFiles(), FileSys::EntryType::File);
|
if (True(mode & OpenDirectoryMode::Directory)) {
|
||||||
BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::EntryType::Directory);
|
BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::EntryType::Directory);
|
||||||
}
|
}
|
||||||
|
if (True(mode & OpenDirectoryMode::File)) {
|
||||||
|
BuildEntryIndex(entries, backend->GetFiles(), FileSys::EntryType::File);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileSys::VirtualDir backend;
|
FileSys::VirtualDir backend;
|
||||||
@ -446,11 +450,9 @@ public:
|
|||||||
|
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBuffer();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
const auto mode = rp.PopRaw<OpenDirectoryMode>();
|
||||||
|
|
||||||
// TODO(Subv): Implement this filter.
|
LOG_DEBUG(Service_FS, "called. directory={}, mode={}", name, mode);
|
||||||
const u32 filter_flags = rp.Pop<u32>();
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called. directory={}, filter={}", name, filter_flags);
|
|
||||||
|
|
||||||
FileSys::VirtualDir vfs_dir{};
|
FileSys::VirtualDir vfs_dir{};
|
||||||
auto result = backend.OpenDirectory(&vfs_dir, name);
|
auto result = backend.OpenDirectory(&vfs_dir, name);
|
||||||
@ -460,7 +462,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto directory = std::make_shared<IDirectory>(system, vfs_dir);
|
auto directory = std::make_shared<IDirectory>(system, vfs_dir, mode);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
Loading…
Reference in New Issue
Block a user