Service/FS: implement IFileSystem::RenameFile
This commit is contained in:
parent
07dc0bbf3e
commit
a0179e5ca5
6 changed files with 36 additions and 8 deletions
|
@ -67,10 +67,16 @@ ResultCode Disk_FileSystem::DeleteFile(const std::string& path) const {
|
|||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const {
|
||||
LOG_WARNING(Service_FS, "(STUBBED) called");
|
||||
ResultCode Disk_FileSystem::RenameFile(const std::string& src_path,
|
||||
const std::string& dest_path) const {
|
||||
const std::string full_src_path = base_directory + src_path;
|
||||
const std::string full_dest_path = base_directory + dest_path;
|
||||
|
||||
if (!FileUtil::Exists(full_src_path)) {
|
||||
return ERROR_PATH_NOT_FOUND;
|
||||
}
|
||||
// TODO(wwylele): Use correct error code
|
||||
return ResultCode(-1);
|
||||
return FileUtil::Rename(full_src_path, full_dest_path) ? RESULT_SUCCESS : ResultCode(-1);
|
||||
}
|
||||
|
||||
ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const {
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
|
||||
Mode mode) const override;
|
||||
ResultCode DeleteFile(const std::string& path) const override;
|
||||
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
|
||||
ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const override;
|
||||
ResultCode DeleteDirectory(const Path& path) const override;
|
||||
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
||||
ResultCode CreateFile(const std::string& path, u64 size) const override;
|
||||
|
|
|
@ -126,7 +126,8 @@ public:
|
|||
* @param dest_path Destination path relative to the archive
|
||||
* @return Result of the operation
|
||||
*/
|
||||
virtual ResultCode RenameFile(const Path& src_path, const Path& dest_path) const = 0;
|
||||
virtual ResultCode RenameFile(const std::string& src_path,
|
||||
const std::string& dest_path) const = 0;
|
||||
|
||||
/**
|
||||
* Rename a Directory specified by its path
|
||||
|
|
|
@ -27,7 +27,8 @@ ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const {
|
|||
return ResultCode(-1);
|
||||
}
|
||||
|
||||
ResultCode RomFS_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const {
|
||||
ResultCode RomFS_FileSystem::RenameFile(const std::string& src_path,
|
||||
const std::string& dest_path) const {
|
||||
LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).",
|
||||
GetName().c_str());
|
||||
// TODO(wwylele): Use correct error code
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
|
||||
Mode mode) const override;
|
||||
ResultCode DeleteFile(const std::string& path) const override;
|
||||
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
|
||||
ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const override;
|
||||
ResultCode DeleteDirectory(const Path& path) const override;
|
||||
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
||||
ResultCode CreateFile(const std::string& path, u64 size) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue