mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-12-27 05:36:42 +00:00
fs/archive: convert Directory to ServiceFramework
This commit is contained in:
parent
4935dcaf56
commit
19d7324075
|
@ -303,42 +303,41 @@ Kernel::SharedPtr<Kernel::ClientSession> File::Connect() {
|
|||
|
||||
Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend,
|
||||
const FileSys::Path& path)
|
||||
: path(path), backend(std::move(backend)) {}
|
||||
: ServiceFramework("", 1), path(path), backend(std::move(backend)) {
|
||||
static const FunctionInfo functions[] = {
|
||||
// clang-format off
|
||||
{0x08010042, &Directory::Read, "Read"},
|
||||
{0x08020000, &Directory::Close, "Close"},
|
||||
// clang-format on
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
Directory::~Directory() {}
|
||||
|
||||
void Directory::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]);
|
||||
switch (cmd) {
|
||||
// Read from directory...
|
||||
case DirectoryCommand::Read: {
|
||||
u32 count = cmd_buff[1];
|
||||
u32 address = cmd_buff[3];
|
||||
void Directory::Read(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x0801, 1, 2);
|
||||
u32 count = rp.Pop<u32>();
|
||||
auto& buffer = rp.PopMappedBuffer();
|
||||
std::vector<FileSys::Entry> entries(count);
|
||||
LOG_TRACE(Service_FS, "Read %s: count=%d", GetName().c_str(), count);
|
||||
|
||||
LOG_TRACE(Service_FS, "Read %s: count=%u", GetName().c_str(), count);
|
||||
// Number of entries actually read
|
||||
u32 read = backend->Read(static_cast<u32>(entries.size()), entries.data());
|
||||
cmd_buff[2] = read;
|
||||
Memory::WriteBlock(address, entries.data(), read * sizeof(FileSys::Entry));
|
||||
break;
|
||||
buffer.Write(entries.data(), 0, read * sizeof(FileSys::Entry));
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push(read);
|
||||
rb.PushMappedBuffer(buffer);
|
||||
}
|
||||
|
||||
case DirectoryCommand::Close: {
|
||||
void Directory::Close(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x0802, 0, 0);
|
||||
LOG_TRACE(Service_FS, "Close %s", GetName().c_str());
|
||||
backend->Close();
|
||||
break;
|
||||
}
|
||||
|
||||
// Unknown command...
|
||||
default:
|
||||
LOG_ERROR(Service_FS, "Unknown command=0x%08X!", static_cast<u32>(cmd));
|
||||
ResultCode error = UnimplementedFunction(ErrorModule::FS);
|
||||
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
|
||||
return;
|
||||
}
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -87,7 +87,7 @@ private:
|
|||
void OpenSubFile(Kernel::HLERequestContext& ctx);
|
||||
};
|
||||
|
||||
class Directory final : public Kernel::SessionRequestHandler {
|
||||
class Directory final : public ServiceFramework<Directory> {
|
||||
public:
|
||||
Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path);
|
||||
~Directory();
|
||||
|
@ -100,11 +100,8 @@ public:
|
|||
std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
|
||||
|
||||
protected:
|
||||
void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
|
||||
|
||||
std::unique_ptr<SessionDataBase> MakeSessionData() const override {
|
||||
return nullptr;
|
||||
}
|
||||
void Read(Kernel::HLERequestContext& ctx);
|
||||
void Close(Kernel::HLERequestContext& ctx);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue