summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/archive_romfs.cpp12
-rw-r--r--src/core/file_sys/archive_sdmc.cpp12
-rw-r--r--src/core/hle/kernel/archive.cpp87
-rw-r--r--src/core/hle/kernel/archive.h14
-rw-r--r--src/core/hle/service/fs_user.cpp10
5 files changed, 41 insertions, 94 deletions
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index d0ca7d380..8c2dbeda5 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -43,12 +43,6 @@ bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const {
43 return false; 43 return false;
44} 44}
45 45
46/**
47 * Rename a File specified by its path
48 * @param src_path Source path relative to the archive
49 * @param dest_path Destination path relative to the archive
50 * @return Whether rename succeeded
51 */
52bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 46bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const {
53 ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS."); 47 ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS.");
54 return false; 48 return false;
@@ -74,12 +68,6 @@ bool Archive_RomFS::CreateDirectory(const Path& path) const {
74 return false; 68 return false;
75} 69}
76 70
77/**
78 * Rename a Directory specified by its path
79 * @param src_path Source path relative to the archive
80 * @param dest_path Destination path relative to the archive
81 * @return Whether rename succeeded
82 */
83bool Archive_RomFS::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 71bool Archive_RomFS::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const {
84 ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS."); 72 ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS.");
85 return false; 73 return false;
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index c8958a0eb..a740a3d59 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -66,12 +66,6 @@ bool Archive_SDMC::DeleteFile(const FileSys::Path& path) const {
66 return FileUtil::Delete(GetMountPoint() + path.AsString()); 66 return FileUtil::Delete(GetMountPoint() + path.AsString());
67} 67}
68 68
69/**
70 * Rename a File specified by its path
71 * @param src_path Source path relative to the archive
72 * @param dest_path Destination path relative to the archive
73 * @return Whether rename succeeded
74 */
75bool Archive_SDMC::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 69bool Archive_SDMC::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const {
76 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); 70 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString());
77} 71}
@@ -94,12 +88,6 @@ bool Archive_SDMC::CreateDirectory(const Path& path) const {
94 return FileUtil::CreateDir(GetMountPoint() + path.AsString()); 88 return FileUtil::CreateDir(GetMountPoint() + path.AsString());
95} 89}
96 90
97/**
98 * Rename a Directory specified by its path
99 * @param src_path Source path relative to the archive
100 * @param dest_path Destination path relative to the archive
101 * @return Whether rename succeeded
102 */
103bool Archive_SDMC::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 91bool Archive_SDMC::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const {
104 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); 92 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString());
105} 93}
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp
index bffe59952..647f0dea9 100644
--- a/src/core/hle/kernel/archive.cpp
+++ b/src/core/hle/kernel/archive.cpp
@@ -340,97 +340,68 @@ ResultVal<Handle> OpenFileFromArchive(Handle archive_handle, const FileSys::Path
340 return MakeResult<Handle>(handle); 340 return MakeResult<Handle>(handle);
341} 341}
342 342
343/** 343ResultCode DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path) {
344 * Delete a File from an Archive
345 * @param archive_handle Handle to an open Archive object
346 * @param path Path to the File inside of the Archive
347 * @return Whether deletion succeeded
348 */
349Result DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path) {
350 Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); 344 Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle);
351 if (archive == nullptr) 345 if (archive == nullptr)
352 return -1; 346 return InvalidHandle(ErrorModule::FS);
353 if (archive->backend->DeleteFile(path)) 347 if (archive->backend->DeleteFile(path))
354 return 0; 348 return RESULT_SUCCESS;
355 return -1; 349 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
350 ErrorSummary::Canceled, ErrorLevel::Status);
356} 351}
357 352
358/** 353ResultCode RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path,
359 * Rename a File between two Archives 354 Handle dest_archive_handle, const FileSys::Path& dest_path) {
360 * @param src_archive_handle Handle to the source Archive object
361 * @param src_path Path to the File inside of the source Archive
362 * @param dest_archive_handle Handle to the destination Archive object
363 * @param dest_path Path to the File inside of the destination Archive
364 * @return Whether rename succeeded
365 */
366Result RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path,
367 Handle dest_archive_handle, const FileSys::Path& dest_path) {
368 Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle); 355 Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle);
369 Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); 356 Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle);
370 if (src_archive == nullptr || dest_archive == nullptr) 357 if (src_archive == nullptr || dest_archive == nullptr)
371 return -1; 358 return InvalidHandle(ErrorModule::FS);
372 if (src_archive == dest_archive) { 359 if (src_archive == dest_archive) {
373 if (src_archive->backend->RenameFile(src_path, dest_path)) 360 if (src_archive->backend->RenameFile(src_path, dest_path))
374 return 0; 361 return RESULT_SUCCESS;
375 } else { 362 } else {
376 // TODO: Implement renaming across archives 363 // TODO: Implement renaming across archives
377 return -1; 364 return UnimplementedFunction(ErrorModule::FS);
378 } 365 }
379 return -1; 366 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
367 ErrorSummary::NothingHappened, ErrorLevel::Status);
380} 368}
381 369
382/** 370ResultCode DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) {
383 * Delete a Directory from an Archive
384 * @param archive_handle Handle to an open Archive object
385 * @param path Path to the Directory inside of the Archive
386 * @return Whether deletion succeeded
387 */
388Result DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) {
389 Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); 371 Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle);
390 if (archive == nullptr) 372 if (archive == nullptr)
391 return -1; 373 return InvalidHandle(ErrorModule::FS);
392 if (archive->backend->DeleteDirectory(path)) 374 if (archive->backend->DeleteDirectory(path))
393 return 0; 375 return RESULT_SUCCESS;
394 return -1; 376 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
377 ErrorSummary::Canceled, ErrorLevel::Status);
395} 378}
396 379
397/** 380ResultCode CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) {
398 * Create a Directory from an Archive
399 * @param archive_handle Handle to an open Archive object
400 * @param path Path to the Directory inside of the Archive
401 * @return Whether creation succeeded
402 */
403Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) {
404 Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); 381 Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle);
405 if (archive == nullptr) 382 if (archive == nullptr)
406 return -1; 383 return InvalidHandle(ErrorModule::FS);
407 if (archive->backend->CreateDirectory(path)) 384 if (archive->backend->CreateDirectory(path))
408 return 0; 385 return RESULT_SUCCESS;
409 return -1; 386 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
387 ErrorSummary::Canceled, ErrorLevel::Status);
410} 388}
411 389
412/** 390ResultCode RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path,
413 * Rename a Directory between two Archives 391 Handle dest_archive_handle, const FileSys::Path& dest_path) {
414 * @param src_archive_handle Handle to the source Archive object
415 * @param src_path Path to the Directory inside of the source Archive
416 * @param dest_archive_handle Handle to the destination Archive object
417 * @param dest_path Path to the Directory inside of the destination Archive
418 * @return Whether rename succeeded
419 */
420Result RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path,
421 Handle dest_archive_handle, const FileSys::Path& dest_path) {
422 Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle); 392 Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle);
423 Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); 393 Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle);
424 if (src_archive == nullptr || dest_archive == nullptr) 394 if (src_archive == nullptr || dest_archive == nullptr)
425 return -1; 395 return InvalidHandle(ErrorModule::FS);
426 if (src_archive == dest_archive) { 396 if (src_archive == dest_archive) {
427 if (src_archive->backend->RenameDirectory(src_path, dest_path)) 397 if (src_archive->backend->RenameDirectory(src_path, dest_path))
428 return 0; 398 return RESULT_SUCCESS;
429 } else { 399 } else {
430 // TODO: Implement renaming across archives 400 // TODO: Implement renaming across archives
431 return -1; 401 return UnimplementedFunction(ErrorModule::FS);
432 } 402 }
433 return -1; 403 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
404 ErrorSummary::NothingHappened, ErrorLevel::Status);
434} 405}
435 406
436/** 407/**
diff --git a/src/core/hle/kernel/archive.h b/src/core/hle/kernel/archive.h
index 9d071d315..b50833a2b 100644
--- a/src/core/hle/kernel/archive.h
+++ b/src/core/hle/kernel/archive.h
@@ -50,7 +50,7 @@ ResultVal<Handle> OpenFileFromArchive(Handle archive_handle, const FileSys::Path
50 * @param path Path to the File inside of the Archive 50 * @param path Path to the File inside of the Archive
51 * @return Whether deletion succeeded 51 * @return Whether deletion succeeded
52 */ 52 */
53Result DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path); 53ResultCode DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path);
54 54
55/** 55/**
56 * Rename a File between two Archives 56 * Rename a File between two Archives
@@ -60,8 +60,8 @@ Result DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path);
60 * @param dest_path Path to the File inside of the destination Archive 60 * @param dest_path Path to the File inside of the destination Archive
61 * @return Whether rename succeeded 61 * @return Whether rename succeeded
62 */ 62 */
63Result RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, 63ResultCode RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path,
64 Handle dest_archive_handle, const FileSys::Path& dest_path); 64 Handle dest_archive_handle, const FileSys::Path& dest_path);
65 65
66/** 66/**
67 * Delete a Directory from an Archive 67 * Delete a Directory from an Archive
@@ -69,7 +69,7 @@ Result RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path&
69 * @param path Path to the Directory inside of the Archive 69 * @param path Path to the Directory inside of the Archive
70 * @return Whether deletion succeeded 70 * @return Whether deletion succeeded
71 */ 71 */
72Result DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path); 72ResultCode DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path);
73 73
74/** 74/**
75 * Create a Directory from an Archive 75 * Create a Directory from an Archive
@@ -77,7 +77,7 @@ Result DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& pa
77 * @param path Path to the Directory inside of the Archive 77 * @param path Path to the Directory inside of the Archive
78 * @return Whether creation of directory succeeded 78 * @return Whether creation of directory succeeded
79 */ 79 */
80Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path); 80ResultCode CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path);
81 81
82/** 82/**
83 * Rename a Directory between two Archives 83 * Rename a Directory between two Archives
@@ -87,8 +87,8 @@ Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& pa
87 * @param dest_path Path to the Directory inside of the destination Archive 87 * @param dest_path Path to the Directory inside of the destination Archive
88 * @return Whether rename succeeded 88 * @return Whether rename succeeded
89 */ 89 */
90Result RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, 90ResultCode RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path,
91 Handle dest_archive_handle, const FileSys::Path& dest_path); 91 Handle dest_archive_handle, const FileSys::Path& dest_path);
92 92
93/** 93/**
94 * Open a Directory from an Archive 94 * Open a Directory from an Archive
diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp
index f4b1a879c..95663b905 100644
--- a/src/core/hle/service/fs_user.cpp
+++ b/src/core/hle/service/fs_user.cpp
@@ -159,7 +159,7 @@ void DeleteFile(Service::Interface* self) {
159 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", 159 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s",
160 filename_type, filename_size, file_path.DebugStr().c_str()); 160 filename_type, filename_size, file_path.DebugStr().c_str());
161 161
162 cmd_buff[1] = Kernel::DeleteFileFromArchive(archive_handle, file_path); 162 cmd_buff[1] = Kernel::DeleteFileFromArchive(archive_handle, file_path).raw;
163 163
164 DEBUG_LOG(KERNEL, "called"); 164 DEBUG_LOG(KERNEL, "called");
165} 165}
@@ -201,7 +201,7 @@ void RenameFile(Service::Interface* self) {
201 src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(), 201 src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(),
202 dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str()); 202 dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str());
203 203
204 cmd_buff[1] = Kernel::RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle, dest_file_path); 204 cmd_buff[1] = Kernel::RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle, dest_file_path).raw;
205 205
206 DEBUG_LOG(KERNEL, "called"); 206 DEBUG_LOG(KERNEL, "called");
207} 207}
@@ -232,7 +232,7 @@ void DeleteDirectory(Service::Interface* self) {
232 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", 232 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s",
233 dirname_type, dirname_size, dir_path.DebugStr().c_str()); 233 dirname_type, dirname_size, dir_path.DebugStr().c_str());
234 234
235 cmd_buff[1] = Kernel::DeleteDirectoryFromArchive(archive_handle, dir_path); 235 cmd_buff[1] = Kernel::DeleteDirectoryFromArchive(archive_handle, dir_path).raw;
236 236
237 DEBUG_LOG(KERNEL, "called"); 237 DEBUG_LOG(KERNEL, "called");
238} 238}
@@ -262,7 +262,7 @@ static void CreateDirectory(Service::Interface* self) {
262 262
263 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); 263 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
264 264
265 cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_path); 265 cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_path).raw;
266 266
267 DEBUG_LOG(KERNEL, "called"); 267 DEBUG_LOG(KERNEL, "called");
268} 268}
@@ -304,7 +304,7 @@ void RenameDirectory(Service::Interface* self) {
304 src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(), 304 src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(),
305 dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str()); 305 dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str());
306 306
307 cmd_buff[1] = Kernel::RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path, dest_archive_handle, dest_dir_path); 307 cmd_buff[1] = Kernel::RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path, dest_archive_handle, dest_dir_path).raw;
308 308
309 DEBUG_LOG(KERNEL, "called"); 309 DEBUG_LOG(KERNEL, "called");
310} 310}