diff options
| author | 2014-11-23 20:02:23 -0500 | |
|---|---|---|
| committer | 2014-11-23 20:02:23 -0500 | |
| commit | ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1 (patch) | |
| tree | 5562cdcd5eaa63021832dab60abfbb2756533838 /src/core/hle/service | |
| parent | Merge pull request #220 from yuriks/patch-1 (diff) | |
| parent | Added DeleteFile and DeleteDirectory functions to FS:USER and the archives. (diff) | |
| download | yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.tar.gz yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.tar.xz yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.zip | |
Merge pull request #191 from archshift/deletexyz
Added DeleteFile and DeleteDirectory functions to FS:USER and the archives.
Diffstat (limited to 'src/core/hle/service')
| -rw-r--r-- | src/core/hle/service/fs_user.cpp | 92 |
1 files changed, 67 insertions, 25 deletions
diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp index dadc89ef8..2aec1a52a 100644 --- a/src/core/hle/service/fs_user.cpp +++ b/src/core/hle/service/fs_user.cpp | |||
| @@ -138,6 +138,68 @@ static void OpenFileDirectly(Service::Interface* self) { | |||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | /* | 140 | /* |
| 141 | * FS_User::DeleteFile service function | ||
| 142 | * Inputs: | ||
| 143 | * 2 : Archive handle lower word | ||
| 144 | * 3 : Archive handle upper word | ||
| 145 | * 4 : File path string type | ||
| 146 | * 5 : File path string size | ||
| 147 | * 7 : File path string data | ||
| 148 | * Outputs: | ||
| 149 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 150 | */ | ||
| 151 | void DeleteFile(Service::Interface* self) { | ||
| 152 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 153 | |||
| 154 | // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to | ||
| 155 | // 3dmoo's or ctrulib's implementations. Triple check if it's really the case. | ||
| 156 | Handle archive_handle = static_cast<Handle>(cmd_buff[3]); | ||
| 157 | auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]); | ||
| 158 | u32 filename_size = cmd_buff[5]; | ||
| 159 | u32 filename_ptr = cmd_buff[7]; | ||
| 160 | |||
| 161 | FileSys::Path file_path(filename_type, filename_size, filename_ptr); | ||
| 162 | |||
| 163 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", | ||
| 164 | filename_type, filename_size, file_path.DebugStr().c_str()); | ||
| 165 | |||
| 166 | cmd_buff[1] = Kernel::DeleteFileFromArchive(archive_handle, file_path); | ||
| 167 | |||
| 168 | DEBUG_LOG(KERNEL, "called"); | ||
| 169 | } | ||
| 170 | |||
| 171 | /* | ||
| 172 | * FS_User::DeleteDirectory service function | ||
| 173 | * Inputs: | ||
| 174 | * 2 : Archive handle lower word | ||
| 175 | * 3 : Archive handle upper word | ||
| 176 | * 4 : Directory path string type | ||
| 177 | * 5 : Directory path string size | ||
| 178 | * 7 : Directory path string data | ||
| 179 | * Outputs: | ||
| 180 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 181 | */ | ||
| 182 | void DeleteDirectory(Service::Interface* self) { | ||
| 183 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 184 | |||
| 185 | // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to | ||
| 186 | // 3dmoo's or ctrulib's implementations. Triple check if it's really the case. | ||
| 187 | Handle archive_handle = static_cast<Handle>(cmd_buff[3]); | ||
| 188 | auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]); | ||
| 189 | u32 dirname_size = cmd_buff[5]; | ||
| 190 | u32 dirname_ptr = cmd_buff[7]; | ||
| 191 | |||
| 192 | FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); | ||
| 193 | |||
| 194 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", | ||
| 195 | dirname_type, dirname_size, dir_path.DebugStr().c_str()); | ||
| 196 | |||
| 197 | cmd_buff[1] = Kernel::DeleteDirectoryFromArchive(archive_handle, dir_path); | ||
| 198 | |||
| 199 | DEBUG_LOG(KERNEL, "called"); | ||
| 200 | } | ||
| 201 | |||
| 202 | /* | ||
| 141 | * FS_User::CreateDirectory service function | 203 | * FS_User::CreateDirectory service function |
| 142 | * Inputs: | 204 | * Inputs: |
| 143 | * 2 : Archive handle lower word | 205 | * 2 : Archive handle lower word |
| @@ -159,18 +221,8 @@ static void CreateDirectory(Service::Interface* self) { | |||
| 159 | u32 dirname_ptr = cmd_buff[8]; | 221 | u32 dirname_ptr = cmd_buff[8]; |
| 160 | 222 | ||
| 161 | FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); | 223 | FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); |
| 162 | std::string dir_string; | ||
| 163 | switch (dir_path.GetType()) { | ||
| 164 | case FileSys::Char: | ||
| 165 | case FileSys::Wchar: | ||
| 166 | dir_string = dir_path.AsString(); | ||
| 167 | break; | ||
| 168 | default: | ||
| 169 | cmd_buff[1] = -1; | ||
| 170 | return; | ||
| 171 | } | ||
| 172 | 224 | ||
| 173 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_string.c_str()); | 225 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); |
| 174 | 226 | ||
| 175 | cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_path); | 227 | cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_path); |
| 176 | 228 | ||
| @@ -188,25 +240,15 @@ static void OpenDirectory(Service::Interface* self) { | |||
| 188 | u32 dirname_ptr = cmd_buff[6]; | 240 | u32 dirname_ptr = cmd_buff[6]; |
| 189 | 241 | ||
| 190 | FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); | 242 | FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); |
| 191 | std::string dir_string; | ||
| 192 | switch (dir_path.GetType()) { | ||
| 193 | case FileSys::Char: | ||
| 194 | case FileSys::Wchar: | ||
| 195 | dir_string = dir_path.AsString(); | ||
| 196 | break; | ||
| 197 | default: | ||
| 198 | cmd_buff[1] = -1; | ||
| 199 | return; | ||
| 200 | } | ||
| 201 | 243 | ||
| 202 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_string.c_str()); | 244 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); |
| 203 | 245 | ||
| 204 | Handle handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_path); | 246 | Handle handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_path); |
| 205 | if (handle) { | 247 | if (handle) { |
| 206 | cmd_buff[1] = 0; | 248 | cmd_buff[1] = 0; |
| 207 | cmd_buff[3] = handle; | 249 | cmd_buff[3] = handle; |
| 208 | } else { | 250 | } else { |
| 209 | ERROR_LOG(KERNEL, "failed to get a handle for directory %s", dir_string.c_str()); | 251 | ERROR_LOG(KERNEL, "failed to get a handle for directory"); |
| 210 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | 252 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. |
| 211 | cmd_buff[1] = -1; | 253 | cmd_buff[1] = -1; |
| 212 | } | 254 | } |
| @@ -279,9 +321,9 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 279 | {0x08010002, Initialize, "Initialize"}, | 321 | {0x08010002, Initialize, "Initialize"}, |
| 280 | {0x080201C2, OpenFile, "OpenFile"}, | 322 | {0x080201C2, OpenFile, "OpenFile"}, |
| 281 | {0x08030204, OpenFileDirectly, "OpenFileDirectly"}, | 323 | {0x08030204, OpenFileDirectly, "OpenFileDirectly"}, |
| 282 | {0x08040142, nullptr, "DeleteFile"}, | 324 | {0x08040142, DeleteFile, "DeleteFile"}, |
| 283 | {0x08050244, nullptr, "RenameFile"}, | 325 | {0x08050244, nullptr, "RenameFile"}, |
| 284 | {0x08060142, nullptr, "DeleteDirectory"}, | 326 | {0x08060142, DeleteDirectory, "DeleteDirectory"}, |
| 285 | {0x08070142, nullptr, "DeleteDirectoryRecursively"}, | 327 | {0x08070142, nullptr, "DeleteDirectoryRecursively"}, |
| 286 | {0x08080202, nullptr, "CreateFile"}, | 328 | {0x08080202, nullptr, "CreateFile"}, |
| 287 | {0x08090182, CreateDirectory, "CreateDirectory"}, | 329 | {0x08090182, CreateDirectory, "CreateDirectory"}, |