From a3107a6b571dedb8828b20ddcb709ec17db9715a Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 11 Nov 2014 19:27:35 -0500 Subject: FileSys: Updated backend code to use FileSys::Path instead of string for paths. --- src/core/hle/service/fs_user.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp index 9dc83291d..1548b9ee5 100644 --- a/src/core/hle/service/fs_user.cpp +++ b/src/core/hle/service/fs_user.cpp @@ -55,7 +55,7 @@ void OpenFile(Service::Interface* self) { DEBUG_LOG(KERNEL, "type=%d size=%d mode=%d attrs=%d data=%s", filename_type, filename_size, mode, attributes, file_string.c_str()); - Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_string, mode); + Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); if (handle) { cmd_buff[1] = 0; cmd_buff[3] = handle; @@ -115,7 +115,7 @@ void OpenFileDirectly(Service::Interface* self) { return; } - Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_string, mode); + Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); if (handle) { cmd_buff[1] = 0; cmd_buff[3] = handle; @@ -163,7 +163,7 @@ void CreateDirectory(Service::Interface* self) { DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_string.c_str()); - cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_string); + cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_path); DEBUG_LOG(KERNEL, "called"); } @@ -192,7 +192,7 @@ void OpenDirectory(Service::Interface* self) { DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_string.c_str()); - Handle handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_string); + Handle handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_path); if (handle) { cmd_buff[1] = 0; cmd_buff[3] = handle; -- cgit v1.2.3 From 3e09c07378a73b959c02830e1c0ffb584a60087c Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 14 Nov 2014 00:07:02 -0500 Subject: FS_User: Support FileSye::Path in a more generic way. added a todo to kernel archive --- src/core/hle/service/fs_user.cpp | 107 ++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 42 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp index 1548b9ee5..8d8f0a201 100644 --- a/src/core/hle/service/fs_user.cpp +++ b/src/core/hle/service/fs_user.cpp @@ -28,6 +28,22 @@ void Initialize(Service::Interface* self) { DEBUG_LOG(KERNEL, "called"); } +/** + * FS_User::OpenFile service function + * Inputs: + * 1 : Transaction + * 2 : Archive handle lower word + * 3 : Archive handle upper word + * 4 : Low path type + * 5 : Low path size + * 6 : Open flags + * 7 : Attributes + * 8 : (LowPathSize << 14) | 2 + * 9 : Low path data pointer + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 3 : File handle + */ void OpenFile(Service::Interface* self) { u32* cmd_buff = Service::GetCommandBuffer(); @@ -39,28 +55,16 @@ void OpenFile(Service::Interface* self) { FileSys::Mode mode; mode.hex = cmd_buff[6]; u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes. u32 filename_ptr = cmd_buff[9]; - FileSys::Path file_path(filename_type, filename_size, filename_ptr); - std::string file_string; - switch (file_path.GetType()) { - case FileSys::Char: - case FileSys::Wchar: - file_string = file_path.AsString(); - break; - default: - WARN_LOG(KERNEL, "file LowPath type is currently unsupported; returning archive handle instead"); - return; - } - DEBUG_LOG(KERNEL, "type=%d size=%d mode=%d attrs=%d data=%s", - filename_type, filename_size, mode, attributes, file_string.c_str()); + DEBUG_LOG(KERNEL, "path=%s, mode=%d attrs=%d", file_path.DebugStr().c_str(), mode, attributes); Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); if (handle) { cmd_buff[1] = 0; cmd_buff[3] = handle; } else { - ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_string.c_str()); + ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. cmd_buff[1] = -1; } @@ -68,6 +72,25 @@ void OpenFile(Service::Interface* self) { DEBUG_LOG(KERNEL, "called"); } +/** + * FS_User::OpenFileDirectly service function + * Inputs: + * 1 : Transaction + * 2 : Archive ID + * 3 : Archive low path type + * 4 : Archive low path size + * 5 : File low path type + * 6 : File low path size + * 7 : Flags + * 8 : Attributes + * 9 : (ArchiveLowPathSize << 14) | 0x802 + * 10 : Archive low path + * 11 : (FileLowPathSize << 14) | 2 + * 12 : File low path + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 3 : File handle + */ void OpenFileDirectly(Service::Interface* self) { u32* cmd_buff = Service::GetCommandBuffer(); @@ -80,47 +103,33 @@ void OpenFileDirectly(Service::Interface* self) { u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes. u32 archivename_ptr = cmd_buff[10]; u32 filename_ptr = cmd_buff[12]; + FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr); + FileSys::Path file_path(filename_type, filename_size, filename_ptr); - DEBUG_LOG(KERNEL, "archive_type=%d archive_size=%d file_type=%d file_size=%d file_mode=%d file_attrs=%d", - archivename_type, archivename_size, filename_type, filename_size, mode, attributes); + DEBUG_LOG(KERNEL, "archive_path=%s file_path=%s, mode=%d attributes=%d", + archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode, attributes); - if (archivename_type != FileSys::Empty) { + if (archive_path.GetType() != FileSys::Empty) { ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); cmd_buff[1] = -1; return; } - // TODO(Link Mauve): check if we should even get a handle for the archive, and don't leak it. + // TODO(Link Mauve): Check if we should even get a handle for the archive, and don't leak it Handle archive_handle = Kernel::OpenArchive(archive_id); - if (archive_handle) { - cmd_buff[1] = 0; - // cmd_buff[2] isn't used according to 3dmoo's implementation. - cmd_buff[3] = archive_handle; - } else { + if (!archive_handle) { ERROR_LOG(KERNEL, "failed to get a handle for archive"); - // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. + // TODO(Link Mauve): Check for the actual error values, this one was just chosen arbitrarily cmd_buff[1] = -1; return; } - FileSys::Path file_path(filename_type, filename_size, filename_ptr); - std::string file_string; - switch (file_path.GetType()) { - case FileSys::Char: - case FileSys::Wchar: - file_string = file_path.AsString(); - break; - default: - WARN_LOG(KERNEL, "file LowPath type is currently unsupported; returning archive handle instead"); - return; - } - Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); if (handle) { cmd_buff[1] = 0; cmd_buff[3] = handle; } else { - ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_string.c_str()); + ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. cmd_buff[1] = -1; } @@ -205,17 +214,31 @@ void OpenDirectory(Service::Interface* self) { DEBUG_LOG(KERNEL, "called"); } +/** + * FS_User::OpenArchive service function + * Inputs: + * 1 : Archive ID + * 2 : Archive low path type + * 3 : Archive low path size + * 4 : (LowPathSize << 14) | 2 + * 5 : Archive low path + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Archive handle lower word (unused) + * 3 : Archive handle upper word (same as file handle) + */ void OpenArchive(Service::Interface* self) { u32* cmd_buff = Service::GetCommandBuffer(); - auto archive_id = static_cast(cmd_buff[1]); + auto archive_id = static_cast(cmd_buff[1]); auto archivename_type = static_cast(cmd_buff[2]); - u32 archivename_size = cmd_buff[3]; - u32 archivename_ptr = cmd_buff[5]; + u32 archivename_size = cmd_buff[3]; + u32 archivename_ptr = cmd_buff[5]; + FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr); - DEBUG_LOG(KERNEL, "type=%d size=%d", archivename_type, archivename_size); + DEBUG_LOG(KERNEL, "archive_path=%s", archive_path.DebugStr().c_str()); - if (archivename_type != FileSys::Empty) { + if (archive_path.GetType() != FileSys::Empty) { ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); cmd_buff[1] = -1; return; -- cgit v1.2.3