HLE/FS: Use IPCHelper in OpenFileDirectly.
This commit is contained in:
parent
90fdc8dcbf
commit
e9a70ce2fc
|
@ -113,18 +113,18 @@ static void OpenFile(Service::Interface* self) {
|
||||||
* 3 : File handle
|
* 3 : File handle
|
||||||
*/
|
*/
|
||||||
static void OpenFileDirectly(Service::Interface* self) {
|
static void OpenFileDirectly(Service::Interface* self) {
|
||||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x803, 8, 4);
|
||||||
|
rp.Skip(1, false); // Transaction
|
||||||
|
|
||||||
auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]);
|
auto archive_id = rp.PopEnum<FS::ArchiveIdCode>();
|
||||||
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[3]);
|
auto archivename_type = rp.PopEnum<FileSys::LowPathType>();
|
||||||
u32 archivename_size = cmd_buff[4];
|
u32 archivename_size = rp.Pop<u32>();
|
||||||
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]);
|
auto filename_type = rp.PopEnum<FileSys::LowPathType>();
|
||||||
u32 filename_size = cmd_buff[6];
|
u32 filename_size = rp.Pop<u32>();
|
||||||
FileSys::Mode mode;
|
FileSys::Mode mode{rp.Pop<u32>()};
|
||||||
mode.hex = cmd_buff[7];
|
u32 attributes = rp.Pop<u32>(); // TODO(Link Mauve): do something with those attributes.
|
||||||
u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
|
u32 archivename_ptr = rp.PopStaticBuffer(nullptr);
|
||||||
u32 archivename_ptr = cmd_buff[10];
|
u32 filename_ptr = rp.PopStaticBuffer(nullptr);
|
||||||
u32 filename_ptr = cmd_buff[12];
|
|
||||||
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
|
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
|
||||||
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
|
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
|
||||||
|
|
||||||
|
@ -132,25 +132,27 @@ static void OpenFileDirectly(Service::Interface* self) {
|
||||||
static_cast<u32>(archive_id), archive_path.DebugStr().c_str(),
|
static_cast<u32>(archive_id), archive_path.DebugStr().c_str(),
|
||||||
file_path.DebugStr().c_str(), mode.hex, attributes);
|
file_path.DebugStr().c_str(), mode.hex, attributes);
|
||||||
|
|
||||||
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||||
|
|
||||||
ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path);
|
ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path);
|
||||||
if (archive_handle.Failed()) {
|
if (archive_handle.Failed()) {
|
||||||
LOG_ERROR(Service_FS,
|
LOG_ERROR(Service_FS,
|
||||||
"Failed to get a handle for archive archive_id=0x%08X archive_path=%s",
|
"Failed to get a handle for archive archive_id=0x%08X archive_path=%s",
|
||||||
static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
|
static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
|
||||||
cmd_buff[1] = archive_handle.Code().raw;
|
rb.Push(archive_handle.Code());
|
||||||
cmd_buff[3] = 0;
|
rb.PushMoveHandles(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SCOPE_EXIT({ CloseArchive(*archive_handle); });
|
SCOPE_EXIT({ CloseArchive(*archive_handle); });
|
||||||
|
|
||||||
ResultVal<std::shared_ptr<File>> file_res =
|
ResultVal<std::shared_ptr<File>> file_res =
|
||||||
OpenFileFromArchive(*archive_handle, file_path, mode);
|
OpenFileFromArchive(*archive_handle, file_path, mode);
|
||||||
cmd_buff[1] = file_res.Code().raw;
|
rb.Push(file_res.Code());
|
||||||
if (file_res.Succeeded()) {
|
if (file_res.Succeeded()) {
|
||||||
std::shared_ptr<File> file = *file_res;
|
std::shared_ptr<File> file = *file_res;
|
||||||
cmd_buff[3] = Kernel::g_handle_table.Create(file->Connect()).Unwrap();
|
rb.PushMoveHandles(Kernel::g_handle_table.Create(file->Connect()).Unwrap());
|
||||||
} else {
|
} else {
|
||||||
cmd_buff[3] = 0;
|
rb.PushMoveHandles(0);
|
||||||
LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%u",
|
LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%u",
|
||||||
file_path.DebugStr().c_str(), mode.hex, attributes);
|
file_path.DebugStr().c_str(), mode.hex, attributes);
|
||||||
}
|
}
|
||||||
|
@ -478,11 +480,11 @@ static void CloseArchive(Service::Interface* self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FS_User::IsSdmcDetected service function
|
* FS_User::IsSdmcDetected service function
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
* 2 : Whether the Sdmc could be detected
|
* 2 : Whether the Sdmc could be detected
|
||||||
*/
|
*/
|
||||||
static void IsSdmcDetected(Service::Interface* self) {
|
static void IsSdmcDetected(Service::Interface* self) {
|
||||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue