diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/archive_backend.h | 7 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.h | 1 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.cpp | 6 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 9 | ||||
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 31 |
8 files changed, 70 insertions, 1 deletions
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h index d69c3c785..06b8f2ed7 100644 --- a/src/core/file_sys/archive_backend.h +++ b/src/core/file_sys/archive_backend.h | |||
| @@ -112,6 +112,13 @@ public: | |||
| 112 | virtual bool DeleteDirectory(const Path& path) const = 0; | 112 | virtual bool DeleteDirectory(const Path& path) const = 0; |
| 113 | 113 | ||
| 114 | /** | 114 | /** |
| 115 | * Delete a directory specified by its path and anything under it | ||
| 116 | * @param path Path relative to the archive | ||
| 117 | * @return Whether the directory could be deleted | ||
| 118 | */ | ||
| 119 | virtual bool DeleteDirectoryRecursively(const Path& path) const = 0; | ||
| 120 | |||
| 121 | /** | ||
| 115 | * Create a file specified by its path | 122 | * Create a file specified by its path |
| 116 | * @param path Path relative to the Archive | 123 | * @param path Path relative to the Archive |
| 117 | * @param size The size of the new file, filled with zeroes | 124 | * @param size The size of the new file, filled with zeroes |
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index 0f66998e1..2f05af361 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp | |||
| @@ -51,6 +51,10 @@ bool DiskArchive::DeleteDirectory(const Path& path) const { | |||
| 51 | return FileUtil::DeleteDir(mount_point + path.AsString()); | 51 | return FileUtil::DeleteDir(mount_point + path.AsString()); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | bool DiskArchive::DeleteDirectoryRecursively(const Path& path) const { | ||
| 55 | return FileUtil::DeleteDirRecursively(mount_point + path.AsString()); | ||
| 56 | } | ||
| 57 | |||
| 54 | ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const { | 58 | ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const { |
| 55 | std::string full_path = mount_point + path.AsString(); | 59 | std::string full_path = mount_point + path.AsString(); |
| 56 | 60 | ||
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h index 2165f27f9..59ebb2002 100644 --- a/src/core/file_sys/disk_archive.h +++ b/src/core/file_sys/disk_archive.h | |||
| @@ -38,6 +38,7 @@ public: | |||
| 38 | ResultCode DeleteFile(const Path& path) const override; | 38 | ResultCode DeleteFile(const Path& path) const override; |
| 39 | bool RenameFile(const Path& src_path, const Path& dest_path) const override; | 39 | bool RenameFile(const Path& src_path, const Path& dest_path) const override; |
| 40 | bool DeleteDirectory(const Path& path) const override; | 40 | bool DeleteDirectory(const Path& path) const override; |
| 41 | bool DeleteDirectoryRecursively(const Path& path) const override; | ||
| 41 | ResultCode CreateFile(const Path& path, u64 size) const override; | 42 | ResultCode CreateFile(const Path& path, u64 size) const override; |
| 42 | bool CreateDirectory(const Path& path) const override; | 43 | bool CreateDirectory(const Path& path) const override; |
| 43 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; | 44 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; |
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp index 49cc1de10..af59d296d 100644 --- a/src/core/file_sys/ivfc_archive.cpp +++ b/src/core/file_sys/ivfc_archive.cpp | |||
| @@ -43,6 +43,12 @@ bool IVFCArchive::DeleteDirectory(const Path& path) const { | |||
| 43 | return false; | 43 | return false; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | bool IVFCArchive::DeleteDirectoryRecursively(const Path& path) const { | ||
| 47 | LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).", | ||
| 48 | GetName().c_str()); | ||
| 49 | return false; | ||
| 50 | } | ||
| 51 | |||
| 46 | ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { | 52 | ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { |
| 47 | LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive (%s).", | 53 | LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive (%s).", |
| 48 | GetName().c_str()); | 54 | GetName().c_str()); |
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h index 0df6cf83a..2fbb3a568 100644 --- a/src/core/file_sys/ivfc_archive.h +++ b/src/core/file_sys/ivfc_archive.h | |||
| @@ -37,6 +37,7 @@ public: | |||
| 37 | ResultCode DeleteFile(const Path& path) const override; | 37 | ResultCode DeleteFile(const Path& path) const override; |
| 38 | bool RenameFile(const Path& src_path, const Path& dest_path) const override; | 38 | bool RenameFile(const Path& src_path, const Path& dest_path) const override; |
| 39 | bool DeleteDirectory(const Path& path) const override; | 39 | bool DeleteDirectory(const Path& path) const override; |
| 40 | bool DeleteDirectoryRecursively(const Path& path) const override; | ||
| 40 | ResultCode CreateFile(const Path& path, u64 size) const override; | 41 | ResultCode CreateFile(const Path& path, u64 size) const override; |
| 41 | bool CreateDirectory(const Path& path) const override; | 42 | bool CreateDirectory(const Path& path) const override; |
| 42 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; | 43 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; |
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 4dc7e1e3c..7f9696bfb 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -362,6 +362,18 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy | |||
| 362 | ErrorSummary::Canceled, ErrorLevel::Status); | 362 | ErrorSummary::Canceled, ErrorLevel::Status); |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, | ||
| 366 | const FileSys::Path& path) { | ||
| 367 | ArchiveBackend* archive = GetArchive(archive_handle); | ||
| 368 | if (archive == nullptr) | ||
| 369 | return ERR_INVALID_ARCHIVE_HANDLE; | ||
| 370 | |||
| 371 | if (archive->DeleteDirectoryRecursively(path)) | ||
| 372 | return RESULT_SUCCESS; | ||
| 373 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 374 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 375 | } | ||
| 376 | |||
| 365 | ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, | 377 | ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, |
| 366 | u64 file_size) { | 378 | u64 file_size) { |
| 367 | ArchiveBackend* archive = GetArchive(archive_handle); | 379 | ArchiveBackend* archive = GetArchive(archive_handle); |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 533be34a4..41a76285c 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -133,6 +133,15 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, | |||
| 133 | ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); | 133 | ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); |
| 134 | 134 | ||
| 135 | /** | 135 | /** |
| 136 | * Delete a Directory and anything under it from an Archive | ||
| 137 | * @param archive_handle Handle to an open Archive object | ||
| 138 | * @param path Path to the Directory inside of the Archive | ||
| 139 | * @return Whether deletion succeeded | ||
| 140 | */ | ||
| 141 | ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, | ||
| 142 | const FileSys::Path& path); | ||
| 143 | |||
| 144 | /** | ||
| 136 | * Create a File in an Archive | 145 | * Create a File in an Archive |
| 137 | * @param archive_handle Handle to an open Archive object | 146 | * @param archive_handle Handle to an open Archive object |
| 138 | * @param path Path to the File inside of the Archive | 147 | * @param path Path to the File inside of the Archive |
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 94f053dc2..582591e40 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -235,6 +235,35 @@ static void DeleteDirectory(Service::Interface* self) { | |||
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | /* | 237 | /* |
| 238 | * FS_User::DeleteDirectoryRecursively service function | ||
| 239 | * Inputs: | ||
| 240 | * 0 : Command header 0x08070142 | ||
| 241 | * 1 : Transaction | ||
| 242 | * 2 : Archive handle lower word | ||
| 243 | * 3 : Archive handle upper word | ||
| 244 | * 4 : Directory path string type | ||
| 245 | * 5 : Directory path string size | ||
| 246 | * 7 : Directory path string data | ||
| 247 | * Outputs: | ||
| 248 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 249 | */ | ||
| 250 | static void DeleteDirectoryRecursively(Service::Interface* self) { | ||
| 251 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 252 | |||
| 253 | ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]); | ||
| 254 | auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]); | ||
| 255 | u32 dirname_size = cmd_buff[5]; | ||
| 256 | u32 dirname_ptr = cmd_buff[7]; | ||
| 257 | |||
| 258 | FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); | ||
| 259 | |||
| 260 | LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, | ||
| 261 | dir_path.DebugStr().c_str()); | ||
| 262 | |||
| 263 | cmd_buff[1] = DeleteDirectoryRecursivelyFromArchive(archive_handle, dir_path).raw; | ||
| 264 | } | ||
| 265 | |||
| 266 | /* | ||
| 238 | * FS_User::CreateFile service function | 267 | * FS_User::CreateFile service function |
| 239 | * Inputs: | 268 | * Inputs: |
| 240 | * 0 : Command header 0x08080202 | 269 | * 0 : Command header 0x08080202 |
| @@ -868,7 +897,7 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 868 | {0x08040142, DeleteFile, "DeleteFile"}, | 897 | {0x08040142, DeleteFile, "DeleteFile"}, |
| 869 | {0x08050244, RenameFile, "RenameFile"}, | 898 | {0x08050244, RenameFile, "RenameFile"}, |
| 870 | {0x08060142, DeleteDirectory, "DeleteDirectory"}, | 899 | {0x08060142, DeleteDirectory, "DeleteDirectory"}, |
| 871 | {0x08070142, nullptr, "DeleteDirectoryRecursively"}, | 900 | {0x08070142, DeleteDirectoryRecursively, "DeleteDirectoryRecursively"}, |
| 872 | {0x08080202, CreateFile, "CreateFile"}, | 901 | {0x08080202, CreateFile, "CreateFile"}, |
| 873 | {0x08090182, CreateDirectory, "CreateDirectory"}, | 902 | {0x08090182, CreateDirectory, "CreateDirectory"}, |
| 874 | {0x080A0244, RenameDirectory, "RenameDirectory"}, | 903 | {0x080A0244, RenameDirectory, "RenameDirectory"}, |