diff options
Diffstat (limited to 'src/core/file_sys/disk_filesystem.cpp')
-rw-r--r-- | src/core/file_sys/disk_filesystem.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp index ca1323873..8aa0e0aa4 100644 --- a/src/core/file_sys/disk_filesystem.cpp +++ b/src/core/file_sys/disk_filesystem.cpp @@ -67,26 +67,32 @@ 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 { - LOG_WARNING(Service_FS, "(STUBBED) called"); + NGLOG_WARNING(Service_FS, "(STUBBED) called"); // TODO(wwylele): Use correct error code return ResultCode(-1); } ResultCode Disk_FileSystem::DeleteDirectoryRecursively(const Path& path) const { - LOG_WARNING(Service_FS, "(STUBBED) called"); + NGLOG_WARNING(Service_FS, "(STUBBED) called"); // TODO(wwylele): Use correct error code return ResultCode(-1); } ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const { - LOG_WARNING(Service_FS, "(STUBBED) called"); + NGLOG_WARNING(Service_FS, "(STUBBED) called"); std::string full_path = base_directory + path; if (size == 0) { @@ -101,7 +107,7 @@ ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const return RESULT_SUCCESS; } - LOG_ERROR(Service_FS, "Too large file"); + NGLOG_ERROR(Service_FS, "Too large file"); // TODO(Subv): Find out the correct error code return ResultCode(-1); } @@ -114,13 +120,13 @@ ResultCode Disk_FileSystem::CreateDirectory(const std::string& path) const { return RESULT_SUCCESS; } - LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating %s", full_path.c_str()); + NGLOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", full_path); // TODO(wwylele): Use correct error code return ResultCode(-1); } ResultCode Disk_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const { - LOG_WARNING(Service_FS, "(STUBBED) called"); + NGLOG_WARNING(Service_FS, "(STUBBED) called"); // TODO(wwylele): Use correct error code return ResultCode(-1); } @@ -140,7 +146,7 @@ ResultVal<std::unique_ptr<DirectoryBackend>> Disk_FileSystem::OpenDirectory( } u64 Disk_FileSystem::GetFreeSpaceSize() const { - LOG_WARNING(Service_FS, "(STUBBED) called"); + NGLOG_WARNING(Service_FS, "(STUBBED) called"); return 0; } @@ -157,14 +163,14 @@ ResultVal<FileSys::EntryType> Disk_FileSystem::GetEntryType(const std::string& p } ResultVal<size_t> Disk_Storage::Read(const u64 offset, const size_t length, u8* buffer) const { - LOG_TRACE(Service_FS, "called offset=%llu, length=%zu", offset, length); + NGLOG_TRACE(Service_FS, "called offset={}, length={}", offset, length); file->Seek(offset, SEEK_SET); return MakeResult<size_t>(file->ReadBytes(buffer, length)); } ResultVal<size_t> Disk_Storage::Write(const u64 offset, const size_t length, const bool flush, const u8* buffer) const { - LOG_WARNING(Service_FS, "(STUBBED) called"); + NGLOG_WARNING(Service_FS, "(STUBBED) called"); file->Seek(offset, SEEK_SET); size_t written = file->WriteBytes(buffer, length); if (flush) { @@ -198,8 +204,7 @@ u64 Disk_Directory::Read(const u64 count, Entry* entries) { const std::string& filename = file.virtualName; Entry& entry = entries[entries_read]; - LOG_TRACE(Service_FS, "File %s: size=%llu dir=%d", filename.c_str(), file.size, - file.isDirectory); + NGLOG_TRACE(Service_FS, "File {}: size={} dir={}", filename, file.size, file.isDirectory); // TODO(Link Mauve): use a proper conversion to UTF-16. for (size_t j = 0; j < FILENAME_LENGTH; ++j) { |