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:
wwylele
2016-10-14 15:29:09 +08:00
parent 958e81404b
commit 4dd8a831bd
6 changed files with 91 additions and 87 deletions

View File

@ -18,7 +18,7 @@ std::string IVFCArchive::GetName() const {
}
ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path,
const Mode mode) const {
const Mode& mode) const {
return MakeResult<std::unique_ptr<FileBackend>>(
std::make_unique<IVFCFile>(romfs_file, data_offset, data_size));
}
@ -31,22 +31,25 @@ ResultCode IVFCArchive::DeleteFile(const Path& path) const {
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).",
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).",
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).",
GetName().c_str());
return false;
// TODO(wwylele): Use correct error code
return ResultCode(-1);
}
ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const {
@ -57,20 +60,22 @@ ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const {
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).",
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).",
GetName().c_str());
return false;
// TODO(wwylele): Use correct error code
return ResultCode(-1);
}
std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) const {
return std::make_unique<IVFCDirectory>();
ResultVal<std::unique_ptr<DirectoryBackend>> IVFCArchive::OpenDirectory(const Path& path) const {
return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<IVFCDirectory>());
}
u64 IVFCArchive::GetFreeBytes() const {