diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/archive.h | 7 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 10 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.h | 7 | ||||
| -rw-r--r-- | src/core/file_sys/archive_sdmc.cpp | 9 | ||||
| -rw-r--r-- | src/core/file_sys/archive_sdmc.h | 7 | ||||
| -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 |
8 files changed, 103 insertions, 4 deletions
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h index 560db6dea..aeabf09ac 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h | |||
| @@ -57,6 +57,13 @@ public: | |||
| 57 | virtual std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const = 0; | 57 | virtual std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const = 0; |
| 58 | 58 | ||
| 59 | /** | 59 | /** |
| 60 | * Create a directory specified by its path | ||
| 61 | * @param path Path relative to the archive | ||
| 62 | * @return Whether the directory could be created | ||
| 63 | */ | ||
| 64 | virtual bool CreateDirectory(const std::string& path) const = 0; | ||
| 65 | |||
| 66 | /** | ||
| 60 | * Open a directory specified by its path | 67 | * Open a directory specified by its path |
| 61 | * @param path Path relative to the archive | 68 | * @param path Path relative to the archive |
| 62 | * @return Opened directory, or nullptr | 69 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index f101fc729..cc759faa8 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp | |||
| @@ -34,6 +34,16 @@ std::unique_ptr<File> Archive_RomFS::OpenFile(const std::string& path, const Mod | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | * Create a directory specified by its path | ||
| 38 | * @param path Path relative to the archive | ||
| 39 | * @return Whether the directory could be created | ||
| 40 | */ | ||
| 41 | bool Archive_RomFS::CreateDirectory(const std::string& path) const { | ||
| 42 | ERROR_LOG(FILESYS, "Attempted to create a directory in ROMFS."); | ||
| 43 | return false; | ||
| 44 | }; | ||
| 45 | |||
| 46 | /** | ||
| 37 | * Open a directory specified by its path | 47 | * Open a directory specified by its path |
| 38 | * @param path Path relative to the archive | 48 | * @param path Path relative to the archive |
| 39 | * @return Opened directory, or nullptr | 49 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index fcdefa95f..ae2344e82 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h | |||
| @@ -37,6 +37,13 @@ public: | |||
| 37 | std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override; | 37 | std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override; |
| 38 | 38 | ||
| 39 | /** | 39 | /** |
| 40 | * Create a directory specified by its path | ||
| 41 | * @param path Path relative to the archive | ||
| 42 | * @return Whether the directory could be created | ||
| 43 | */ | ||
| 44 | bool CreateDirectory(const std::string& path) const override; | ||
| 45 | |||
| 46 | /** | ||
| 40 | * Open a directory specified by its path | 47 | * Open a directory specified by its path |
| 41 | * @param path Path relative to the archive | 48 | * @param path Path relative to the archive |
| 42 | * @return Opened directory, or nullptr | 49 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index 0b647f7d0..66931e93e 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp | |||
| @@ -58,6 +58,15 @@ std::unique_ptr<File> Archive_SDMC::OpenFile(const std::string& path, const Mode | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | * Create a directory specified by its path | ||
| 62 | * @param path Path relative to the archive | ||
| 63 | * @return Whether the directory could be created | ||
| 64 | */ | ||
| 65 | bool Archive_SDMC::CreateDirectory(const std::string& path) const { | ||
| 66 | return FileUtil::CreateDir(GetMountPoint() + path); | ||
| 67 | } | ||
| 68 | |||
| 69 | /** | ||
| 61 | * Open a directory specified by its path | 70 | * Open a directory specified by its path |
| 62 | * @param path Path relative to the archive | 71 | * @param path Path relative to the archive |
| 63 | * @return Opened directory, or nullptr | 72 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h index f68648e6f..0e059b635 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h | |||
| @@ -41,6 +41,13 @@ public: | |||
| 41 | std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override; | 41 | std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override; |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| 44 | * Create a directory specified by its path | ||
| 45 | * @param path Path relative to the archive | ||
| 46 | * @return Whether the directory could be created | ||
| 47 | */ | ||
| 48 | bool CreateDirectory(const std::string& path) const override; | ||
| 49 | |||
| 50 | /** | ||
| 44 | * Open a directory specified by its path | 51 | * Open a directory specified by its path |
| 45 | * @param path Path relative to the archive | 52 | * @param path Path relative to the archive |
| 46 | * @return Opened directory, or nullptr | 53 | * @return Opened directory, or nullptr |
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"}, |