|
|
@ -20,7 +20,6 @@
|
|
|
|
#include "core/file_sys/archive_sdmc.h"
|
|
|
|
#include "core/file_sys/archive_sdmc.h"
|
|
|
|
#include "core/file_sys/directory_backend.h"
|
|
|
|
#include "core/file_sys/directory_backend.h"
|
|
|
|
#include "core/hle/service/fs/archive.h"
|
|
|
|
#include "core/hle/service/fs/archive.h"
|
|
|
|
#include "core/hle/kernel/session.h"
|
|
|
|
|
|
|
|
#include "core/hle/result.h"
|
|
|
|
#include "core/hle/result.h"
|
|
|
|
|
|
|
|
|
|
|
|
// Specializes std::hash for ArchiveIdCode, so that we can use it in std::unordered_map.
|
|
|
|
// Specializes std::hash for ArchiveIdCode, so that we can use it in std::unordered_map.
|
|
|
@ -76,19 +75,7 @@ enum class DirectoryCommand : u32 {
|
|
|
|
Close = 0x08020000,
|
|
|
|
Close = 0x08020000,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class File : public Kernel::Session {
|
|
|
|
ResultVal<bool> File::SyncRequest() {
|
|
|
|
public:
|
|
|
|
|
|
|
|
File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path)
|
|
|
|
|
|
|
|
: path(path), priority(0), backend(std::move(backend)) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string GetName() const override { return "Path: " + path.DebugStr(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileSys::Path path; ///< Path of the file
|
|
|
|
|
|
|
|
u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
|
|
|
|
|
|
|
|
std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<bool> SyncRequest() override {
|
|
|
|
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
|
|
|
|
FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
|
|
|
|
switch (cmd) {
|
|
|
|
switch (cmd) {
|
|
|
@ -178,23 +165,11 @@ public:
|
|
|
|
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
|
|
|
|
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
|
|
|
|
return error;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmd_buff[1] = 0; // No error
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
|
|
|
return MakeResult<bool>(false);
|
|
|
|
return MakeResult<bool>(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Directory : public Kernel::Session {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path)
|
|
|
|
|
|
|
|
: path(path), backend(std::move(backend)) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string GetName() const override { return "Directory: " + path.DebugStr(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileSys::Path path; ///< Path of the directory
|
|
|
|
ResultVal<bool> Directory::SyncRequest() {
|
|
|
|
std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<bool> SyncRequest() override {
|
|
|
|
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]);
|
|
|
|
DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]);
|
|
|
|
switch (cmd) {
|
|
|
|
switch (cmd) {
|
|
|
@ -227,10 +202,9 @@ public:
|
|
|
|
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
|
|
|
|
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
|
|
|
|
return MakeResult<bool>(false);
|
|
|
|
return MakeResult<bool>(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmd_buff[1] = 0; // No error
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
|
|
|
return MakeResult<bool>(false);
|
|
|
|
return MakeResult<bool>(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
@ -294,7 +268,7 @@ ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factor
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenFileFromArchive(ArchiveHandle archive_handle,
|
|
|
|
ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
|
|
|
|
const FileSys::Path& path, const FileSys::Mode mode) {
|
|
|
|
const FileSys::Path& path, const FileSys::Mode mode) {
|
|
|
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
|
|
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
|
|
|
if (archive == nullptr)
|
|
|
|
if (archive == nullptr)
|
|
|
@ -307,7 +281,7 @@ ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenFileFromArchive(ArchiveHandle
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto file = Kernel::SharedPtr<File>(new File(std::move(backend), path));
|
|
|
|
auto file = Kernel::SharedPtr<File>(new File(std::move(backend), path));
|
|
|
|
return MakeResult<Kernel::SharedPtr<Kernel::Session>>(std::move(file));
|
|
|
|
return MakeResult<Kernel::SharedPtr<File>>(std::move(file));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
|
|
|
ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
|
|
@ -393,7 +367,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
|
|
|
|
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
|
|
|
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
|
|
|
|
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
|
|
|
|
const FileSys::Path& path) {
|
|
|
|
const FileSys::Path& path) {
|
|
|
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
|
|
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
|
|
|
if (archive == nullptr)
|
|
|
|
if (archive == nullptr)
|
|
|
@ -406,7 +380,7 @@ ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenDirectoryFromArchive(ArchiveHa
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path));
|
|
|
|
auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path));
|
|
|
|
return MakeResult<Kernel::SharedPtr<Kernel::Session>>(std::move(directory));
|
|
|
|
return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResultCode FormatSaveData() {
|
|
|
|
ResultCode FormatSaveData() {
|
|
|
|