diff options
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/kernel/archive.cpp | 15 | ||||
| -rw-r--r-- | src/core/hle/kernel/archive.h | 12 | ||||
| -rw-r--r-- | src/core/hle/service/fs_user.cpp | 40 |
3 files changed, 63 insertions, 4 deletions
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index 4a6140c71..764082d71 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp | |||
| @@ -381,6 +381,21 @@ Handle OpenFileFromArchive(Handle archive_handle, const std::string& path, const | |||
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | /** | 383 | /** |
| 384 | * Create a Directory from an Archive | ||
| 385 | * @param archive_handle Handle to an open Archive object | ||
| 386 | * @param path Path to the Directory inside of the Archive | ||
| 387 | * @return Opened Directory object | ||
| 388 | */ | ||
| 389 | Result CreateDirectoryFromArchive(Handle archive_handle, const std::string& path) { | ||
| 390 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); | ||
| 391 | if (archive == nullptr) | ||
| 392 | return -1; | ||
| 393 | if (archive->backend->CreateDirectory(path)) | ||
| 394 | return 0; | ||
| 395 | return -1; | ||
| 396 | } | ||
| 397 | |||
| 398 | /** | ||
| 384 | * Open a Directory from an Archive | 399 | * Open a Directory from an Archive |
| 385 | * @param archive_handle Handle to an open Archive object | 400 | * @param archive_handle Handle to an open Archive object |
| 386 | * @param path Path to the Directory inside of the Archive | 401 | * @param path Path to the Directory inside of the Archive |
diff --git a/src/core/hle/kernel/archive.h b/src/core/hle/kernel/archive.h index 593861f8e..0230996b6 100644 --- a/src/core/hle/kernel/archive.h +++ b/src/core/hle/kernel/archive.h | |||
| @@ -43,7 +43,15 @@ Handle CreateArchive(FileSys::Archive* backend, const std::string& name); | |||
| 43 | * @param mode Mode under which to open the File | 43 | * @param mode Mode under which to open the File |
| 44 | * @return Opened File object | 44 | * @return Opened File object |
| 45 | */ | 45 | */ |
| 46 | Handle OpenFileFromArchive(Handle handle, const std::string& name, const FileSys::Mode mode); | 46 | Handle OpenFileFromArchive(Handle archive_handle, const std::string& name, const FileSys::Mode mode); |
| 47 | |||
| 48 | /** | ||
| 49 | * Create a Directory from an Archive | ||
| 50 | * @param archive_handle Handle to an open Archive object | ||
| 51 | * @param path Path to the Directory inside of the Archive | ||
| 52 | * @return Whether creation of directory succeeded | ||
| 53 | */ | ||
| 54 | Result CreateDirectoryFromArchive(Handle archive_handle, const std::string& name); | ||
| 47 | 55 | ||
| 48 | /** | 56 | /** |
| 49 | * Open a Directory from an Archive | 57 | * Open a Directory from an Archive |
| @@ -51,7 +59,7 @@ Handle OpenFileFromArchive(Handle handle, const std::string& name, const FileSys | |||
| 51 | * @param path Path to the Directory inside of the Archive | 59 | * @param path Path to the Directory inside of the Archive |
| 52 | * @return Opened Directory object | 60 | * @return Opened Directory object |
| 53 | */ | 61 | */ |
| 54 | Handle OpenDirectoryFromArchive(Handle handle, const std::string& name); | 62 | Handle OpenDirectoryFromArchive(Handle archive_handle, const std::string& name); |
| 55 | 63 | ||
| 56 | /// Initialize archives | 64 | /// Initialize archives |
| 57 | void ArchiveInit(); | 65 | void ArchiveInit(); |
diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp index 845c94103..48d806e2f 100644 --- a/src/core/hle/service/fs_user.cpp +++ b/src/core/hle/service/fs_user.cpp | |||
| @@ -100,7 +100,7 @@ void OpenFileDirectly(Service::Interface* self) { | |||
| 100 | std::string archive_name = GetStringFromCmdBuff(archive_pointer, archive_size); | 100 | std::string archive_name = GetStringFromCmdBuff(archive_pointer, archive_size); |
| 101 | std::string file_name = GetStringFromCmdBuff(pointer, size); | 101 | std::string file_name = GetStringFromCmdBuff(pointer, size); |
| 102 | 102 | ||
| 103 | DEBUG_LOG(KERNEL, "archive_type=%d archive_size=%d archive_data=%s" | 103 | DEBUG_LOG(KERNEL, "archive_type=%d archive_size=%d archive_data=%s " |
| 104 | "file_type=%d file_size=%d file_mode=%d file_attrs=%d file_data=%s", | 104 | "file_type=%d file_size=%d file_mode=%d file_attrs=%d file_data=%s", |
| 105 | archive_type, archive_size, archive_name.c_str(), | 105 | archive_type, archive_size, archive_name.c_str(), |
| 106 | file_type, size, mode, attributes, file_name.c_str()); | 106 | file_type, size, mode, attributes, file_name.c_str()); |
| @@ -136,6 +136,42 @@ void OpenFileDirectly(Service::Interface* self) { | |||
| 136 | DEBUG_LOG(KERNEL, "called"); | 136 | DEBUG_LOG(KERNEL, "called"); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | /* | ||
| 140 | * FS_User::CreateDirectory service function | ||
| 141 | * Inputs: | ||
| 142 | * 2 : Archive handle lower word | ||
| 143 | * 3 : Archive handle upper word | ||
| 144 | * 4 : Directory path string type | ||
| 145 | * 5 : Directory path string size | ||
| 146 | * 8 : Directory path string data | ||
| 147 | * Outputs: | ||
| 148 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 149 | */ | ||
| 150 | void CreateDirectory(Service::Interface* self) { | ||
| 151 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 152 | |||
| 153 | // TODO: cmd_buff[2], aka archive handle lower word, isn't used according to | ||
| 154 | // 3dmoo's or ctrulib's implementations. Triple check if it's really the case. | ||
| 155 | Handle archive_handle = static_cast<Handle>(cmd_buff[3]); | ||
| 156 | LowPathType type = static_cast<LowPathType>(cmd_buff[4]); | ||
| 157 | u32 name_size = cmd_buff[5]; | ||
| 158 | u32 name_offset = cmd_buff[8]; | ||
| 159 | |||
| 160 | if (type != LowPathType::Char) { | ||
| 161 | ERROR_LOG(KERNEL, "directory LowPath type other than char is currently unsupported"); | ||
| 162 | cmd_buff[1] = -1; | ||
| 163 | return; | ||
| 164 | } | ||
| 165 | |||
| 166 | std::string dir_name = GetStringFromCmdBuff(name_offset, name_size); | ||
| 167 | |||
| 168 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", type, name_size, dir_name.c_str()); | ||
| 169 | |||
| 170 | cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_name); | ||
| 171 | |||
| 172 | DEBUG_LOG(KERNEL, "called"); | ||
| 173 | } | ||
| 174 | |||
| 139 | void OpenDirectory(Service::Interface* self) { | 175 | void OpenDirectory(Service::Interface* self) { |
| 140 | u32* cmd_buff = Service::GetCommandBuffer(); | 176 | u32* cmd_buff = Service::GetCommandBuffer(); |
| 141 | 177 | ||
| @@ -227,7 +263,7 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 227 | {0x08060142, nullptr, "DeleteDirectory"}, | 263 | {0x08060142, nullptr, "DeleteDirectory"}, |
| 228 | {0x08070142, nullptr, "DeleteDirectoryRecursively"}, | 264 | {0x08070142, nullptr, "DeleteDirectoryRecursively"}, |
| 229 | {0x08080202, nullptr, "CreateFile"}, | 265 | {0x08080202, nullptr, "CreateFile"}, |
| 230 | {0x08090182, nullptr, "CreateDirectory"}, | 266 | {0x08090182, CreateDirectory, "CreateDirectory"}, |
| 231 | {0x080A0244, nullptr, "RenameDirectory"}, | 267 | {0x080A0244, nullptr, "RenameDirectory"}, |
| 232 | {0x080B0102, OpenDirectory, "OpenDirectory"}, | 268 | {0x080B0102, OpenDirectory, "OpenDirectory"}, |
| 233 | {0x080C00C2, OpenArchive, "OpenArchive"}, | 269 | {0x080C00C2, OpenArchive, "OpenArchive"}, |