mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-02 16:35:06 +01:00
FileSys: make Archive interfaces return error code
and make the mode parameter a reference since it is a BitField union
This commit is contained in:
parent
958e81404b
commit
4dd8a831bd
@ -87,7 +87,7 @@ public:
|
|||||||
* @return Opened file, or error code
|
* @return Opened file, or error code
|
||||||
*/
|
*/
|
||||||
virtual ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
|
virtual ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
|
||||||
const Mode mode) const = 0;
|
const Mode& mode) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a file specified by its path
|
* Delete a file specified by its path
|
||||||
@ -100,53 +100,53 @@ public:
|
|||||||
* Rename a File specified by its path
|
* Rename a File specified by its path
|
||||||
* @param src_path Source path relative to the archive
|
* @param src_path Source path relative to the archive
|
||||||
* @param dest_path Destination path relative to the archive
|
* @param dest_path Destination path relative to the archive
|
||||||
* @return Whether rename succeeded
|
* @return Result of the operation
|
||||||
*/
|
*/
|
||||||
virtual bool RenameFile(const Path& src_path, const Path& dest_path) const = 0;
|
virtual ResultCode RenameFile(const Path& src_path, const Path& dest_path) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a directory specified by its path
|
* Delete a directory specified by its path
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
* @return Whether the directory could be deleted
|
* @return Result of the operation
|
||||||
*/
|
*/
|
||||||
virtual bool DeleteDirectory(const Path& path) const = 0;
|
virtual ResultCode DeleteDirectory(const Path& path) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a directory specified by its path and anything under it
|
* Delete a directory specified by its path and anything under it
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
* @return Whether the directory could be deleted
|
* @return Result of the operation
|
||||||
*/
|
*/
|
||||||
virtual bool DeleteDirectoryRecursively(const Path& path) const = 0;
|
virtual ResultCode DeleteDirectoryRecursively(const Path& path) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a file specified by its path
|
* Create a file specified by its path
|
||||||
* @param path Path relative to the Archive
|
* @param path Path relative to the Archive
|
||||||
* @param size The size of the new file, filled with zeroes
|
* @param size The size of the new file, filled with zeroes
|
||||||
* @return File creation result code
|
* @return Result of the operation
|
||||||
*/
|
*/
|
||||||
virtual ResultCode CreateFile(const Path& path, u64 size) const = 0;
|
virtual ResultCode CreateFile(const Path& path, u64 size) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory specified by its path
|
* Create a directory specified by its path
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
* @return Whether the directory could be created
|
* @return Result of the operation
|
||||||
*/
|
*/
|
||||||
virtual bool CreateDirectory(const Path& path) const = 0;
|
virtual ResultCode CreateDirectory(const Path& path) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename a Directory specified by its path
|
* Rename a Directory specified by its path
|
||||||
* @param src_path Source path relative to the archive
|
* @param src_path Source path relative to the archive
|
||||||
* @param dest_path Destination path relative to the archive
|
* @param dest_path Destination path relative to the archive
|
||||||
* @return Whether rename succeeded
|
* @return Result of the operation
|
||||||
*/
|
*/
|
||||||
virtual bool RenameDirectory(const Path& src_path, const Path& dest_path) const = 0;
|
virtual ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a directory specified by its path
|
* Open a directory specified by its path
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
* @return Opened directory, or nullptr
|
* @return Opened directory, or error code
|
||||||
*/
|
*/
|
||||||
virtual std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const = 0;
|
virtual ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the free space
|
* Get the free space
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
ResultVal<std::unique_ptr<FileBackend>> DiskArchive::OpenFile(const Path& path,
|
ResultVal<std::unique_ptr<FileBackend>> DiskArchive::OpenFile(const Path& path,
|
||||||
const Mode mode) const {
|
const Mode& mode) const {
|
||||||
LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex);
|
LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex);
|
||||||
auto file = std::make_unique<DiskFile>(*this, path, mode);
|
auto file = std::make_unique<DiskFile>(*this, path, mode);
|
||||||
ResultCode result = file->Open();
|
ResultCode result = file->Open();
|
||||||
@ -43,16 +43,28 @@ ResultCode DiskArchive::DeleteFile(const Path& path) const {
|
|||||||
ErrorLevel::Status);
|
ErrorLevel::Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
|
ResultCode DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
|
||||||
return FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString());
|
if (FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString()))
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
|
||||||
|
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
|
||||||
|
// exist or similar. Verify.
|
||||||
|
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
||||||
|
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiskArchive::DeleteDirectory(const Path& path) const {
|
ResultCode DiskArchive::DeleteDirectory(const Path& path) const {
|
||||||
return FileUtil::DeleteDir(mount_point + path.AsString());
|
if (FileUtil::DeleteDir(mount_point + path.AsString()))
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
||||||
|
ErrorSummary::Canceled, ErrorLevel::Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiskArchive::DeleteDirectoryRecursively(const Path& path) const {
|
ResultCode DiskArchive::DeleteDirectoryRecursively(const Path& path) const {
|
||||||
return FileUtil::DeleteDirRecursively(mount_point + path.AsString());
|
if (FileUtil::DeleteDirRecursively(mount_point + path.AsString()))
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
||||||
|
ErrorSummary::Canceled, ErrorLevel::Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const {
|
ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const {
|
||||||
@ -81,20 +93,30 @@ ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const {
|
|||||||
ErrorLevel::Info);
|
ErrorLevel::Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiskArchive::CreateDirectory(const Path& path) const {
|
ResultCode DiskArchive::CreateDirectory(const Path& path) const {
|
||||||
return FileUtil::CreateDir(mount_point + path.AsString());
|
if (FileUtil::CreateDir(mount_point + path.AsString()))
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
||||||
|
ErrorSummary::Canceled, ErrorLevel::Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
|
ResultCode DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
|
||||||
return FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString());
|
if (FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString()))
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
|
||||||
|
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
|
||||||
|
// exist or similar. Verify.
|
||||||
|
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
||||||
|
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) const {
|
ResultVal<std::unique_ptr<DirectoryBackend>> DiskArchive::OpenDirectory(const Path& path) const {
|
||||||
LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str());
|
LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str());
|
||||||
auto directory = std::make_unique<DiskDirectory>(*this, path);
|
auto directory = std::make_unique<DiskDirectory>(*this, path);
|
||||||
if (!directory->Open())
|
if (!directory->Open())
|
||||||
return nullptr;
|
return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound,
|
||||||
return std::move(directory);
|
ErrorLevel::Permanent);
|
||||||
|
return MakeResult<std::unique_ptr<DirectoryBackend>>(std::move(directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 DiskArchive::GetFreeBytes() const {
|
u64 DiskArchive::GetFreeBytes() const {
|
||||||
|
@ -34,15 +34,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
|
ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
|
||||||
const Mode mode) const override;
|
const Mode& mode) const override;
|
||||||
ResultCode DeleteFile(const Path& path) const override;
|
ResultCode DeleteFile(const Path& path) const override;
|
||||||
bool RenameFile(const Path& src_path, const Path& dest_path) const override;
|
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
|
||||||
bool DeleteDirectory(const Path& path) const override;
|
ResultCode DeleteDirectory(const Path& path) const override;
|
||||||
bool DeleteDirectoryRecursively(const Path& path) const override;
|
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
||||||
ResultCode CreateFile(const Path& path, u64 size) const override;
|
ResultCode CreateFile(const Path& path, u64 size) const override;
|
||||||
bool CreateDirectory(const Path& path) const override;
|
ResultCode CreateDirectory(const Path& path) const override;
|
||||||
bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
|
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override;
|
||||||
std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override;
|
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override;
|
||||||
u64 GetFreeBytes() const override;
|
u64 GetFreeBytes() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -18,7 +18,7 @@ std::string IVFCArchive::GetName() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path,
|
ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path,
|
||||||
const Mode mode) const {
|
const Mode& mode) const {
|
||||||
return MakeResult<std::unique_ptr<FileBackend>>(
|
return MakeResult<std::unique_ptr<FileBackend>>(
|
||||||
std::make_unique<IVFCFile>(romfs_file, data_offset, data_size));
|
std::make_unique<IVFCFile>(romfs_file, data_offset, data_size));
|
||||||
}
|
}
|
||||||
@ -31,22 +31,25 @@ ResultCode IVFCArchive::DeleteFile(const Path& path) const {
|
|||||||
ErrorLevel::Status);
|
ErrorLevel::Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
|
ResultCode IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
|
||||||
LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).",
|
LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).",
|
||||||
GetName().c_str());
|
GetName().c_str());
|
||||||
return false;
|
// TODO(wwylele): Use correct error code
|
||||||
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IVFCArchive::DeleteDirectory(const Path& path) const {
|
ResultCode IVFCArchive::DeleteDirectory(const Path& path) const {
|
||||||
LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).",
|
LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).",
|
||||||
GetName().c_str());
|
GetName().c_str());
|
||||||
return false;
|
// TODO(wwylele): Use correct error code
|
||||||
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IVFCArchive::DeleteDirectoryRecursively(const Path& path) const {
|
ResultCode IVFCArchive::DeleteDirectoryRecursively(const Path& path) const {
|
||||||
LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).",
|
LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).",
|
||||||
GetName().c_str());
|
GetName().c_str());
|
||||||
return false;
|
// TODO(wwylele): Use correct error code
|
||||||
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const {
|
ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const {
|
||||||
@ -57,20 +60,22 @@ ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const {
|
|||||||
ErrorLevel::Permanent);
|
ErrorLevel::Permanent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IVFCArchive::CreateDirectory(const Path& path) const {
|
ResultCode IVFCArchive::CreateDirectory(const Path& path) const {
|
||||||
LOG_CRITICAL(Service_FS, "Attempted to create a directory in an IVFC archive (%s).",
|
LOG_CRITICAL(Service_FS, "Attempted to create a directory in an IVFC archive (%s).",
|
||||||
GetName().c_str());
|
GetName().c_str());
|
||||||
return false;
|
// TODO(wwylele): Use correct error code
|
||||||
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
|
ResultCode IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
|
||||||
LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).",
|
LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).",
|
||||||
GetName().c_str());
|
GetName().c_str());
|
||||||
return false;
|
// TODO(wwylele): Use correct error code
|
||||||
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) const {
|
ResultVal<std::unique_ptr<DirectoryBackend>> IVFCArchive::OpenDirectory(const Path& path) const {
|
||||||
return std::make_unique<IVFCDirectory>();
|
return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<IVFCDirectory>());
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 IVFCArchive::GetFreeBytes() const {
|
u64 IVFCArchive::GetFreeBytes() const {
|
||||||
|
@ -33,15 +33,15 @@ public:
|
|||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
|
|
||||||
ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
|
ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
|
||||||
const Mode mode) const override;
|
const Mode& mode) const override;
|
||||||
ResultCode DeleteFile(const Path& path) const override;
|
ResultCode DeleteFile(const Path& path) const override;
|
||||||
bool RenameFile(const Path& src_path, const Path& dest_path) const override;
|
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
|
||||||
bool DeleteDirectory(const Path& path) const override;
|
ResultCode DeleteDirectory(const Path& path) const override;
|
||||||
bool DeleteDirectoryRecursively(const Path& path) const override;
|
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
||||||
ResultCode CreateFile(const Path& path, u64 size) const override;
|
ResultCode CreateFile(const Path& path, u64 size) const override;
|
||||||
bool CreateDirectory(const Path& path) const override;
|
ResultCode CreateDirectory(const Path& path) const override;
|
||||||
bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
|
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override;
|
||||||
std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override;
|
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override;
|
||||||
u64 GetFreeBytes() const override;
|
u64 GetFreeBytes() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -338,17 +338,11 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
|
|||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
if (src_archive == dest_archive) {
|
if (src_archive == dest_archive) {
|
||||||
if (src_archive->RenameFile(src_path, dest_path))
|
return src_archive->RenameFile(src_path, dest_path);
|
||||||
return RESULT_SUCCESS;
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: Implement renaming across archives
|
// TODO: Implement renaming across archives
|
||||||
return UnimplementedFunction(ErrorModule::FS);
|
return UnimplementedFunction(ErrorModule::FS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
|
|
||||||
// exist or similar. Verify.
|
|
||||||
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
|
||||||
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
||||||
@ -356,10 +350,7 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
|
|||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
if (archive->DeleteDirectory(path))
|
return archive->DeleteDirectory(path);
|
||||||
return RESULT_SUCCESS;
|
|
||||||
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
|
ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
|
||||||
@ -368,10 +359,7 @@ ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
|
|||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
if (archive->DeleteDirectoryRecursively(path))
|
return archive->DeleteDirectoryRecursively(path);
|
||||||
return RESULT_SUCCESS;
|
|
||||||
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
|
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
|
||||||
@ -388,10 +376,7 @@ ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
|
|||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
if (archive->CreateDirectory(path))
|
return archive->CreateDirectory(path);
|
||||||
return RESULT_SUCCESS;
|
|
||||||
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
|
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
|
||||||
@ -404,17 +389,11 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
|
|||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
if (src_archive == dest_archive) {
|
if (src_archive == dest_archive) {
|
||||||
if (src_archive->RenameDirectory(src_path, dest_path))
|
return src_archive->RenameDirectory(src_path, dest_path);
|
||||||
return RESULT_SUCCESS;
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: Implement renaming across archives
|
// TODO: Implement renaming across archives
|
||||||
return UnimplementedFunction(ErrorModule::FS);
|
return UnimplementedFunction(ErrorModule::FS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
|
|
||||||
// exist or similar. Verify.
|
|
||||||
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
|
||||||
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
|
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
|
||||||
@ -423,13 +402,11 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a
|
|||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
std::unique_ptr<FileSys::DirectoryBackend> backend = archive->OpenDirectory(path);
|
auto backend = archive->OpenDirectory(path);
|
||||||
if (backend == nullptr) {
|
if (backend.Failed())
|
||||||
return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound,
|
return backend.Code();
|
||||||
ErrorLevel::Permanent);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path));
|
auto directory = Kernel::SharedPtr<Directory>(new Directory(backend.MoveFrom(), path));
|
||||||
return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory));
|
return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user