mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-15 02:20:06 +00:00
Reorder error handling in extdata FS::CreateFile (#7346)
* Reorder error handling in extdata CreateFile * Apply suggestions
This commit is contained in:
parent
30c53c9509
commit
72c1075402
@ -92,7 +92,7 @@ class ExtSaveDataArchive : public SaveDataArchive {
|
|||||||
public:
|
public:
|
||||||
explicit ExtSaveDataArchive(const std::string& mount_point,
|
explicit ExtSaveDataArchive(const std::string& mount_point,
|
||||||
std::unique_ptr<DelayGenerator> delay_generator_)
|
std::unique_ptr<DelayGenerator> delay_generator_)
|
||||||
: SaveDataArchive(mount_point) {
|
: SaveDataArchive(mount_point, false) {
|
||||||
delay_generator = std::move(delay_generator_);
|
delay_generator = std::move(delay_generator_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,14 +155,6 @@ public:
|
|||||||
std::move(delay_generator));
|
std::move(delay_generator));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result CreateFile(const Path& path, u64 size) const override {
|
|
||||||
if (size == 0) {
|
|
||||||
LOG_ERROR(Service_FS, "Zero-size file is not supported");
|
|
||||||
return ResultUnsupportedOpenFlags;
|
|
||||||
}
|
|
||||||
return SaveDataArchive::CreateFile(path, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExtSaveDataArchive() = default;
|
ExtSaveDataArchive() = default;
|
||||||
template <class Archive>
|
template <class Archive>
|
||||||
|
@ -232,8 +232,13 @@ Result SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
|
if (allow_zero_size_create) {
|
||||||
FileUtil::CreateEmptyFile(full_path);
|
FileUtil::CreateEmptyFile(full_path);
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG(Service_FS, "Zero-size file is not supported");
|
||||||
|
return ResultUnsupportedOpenFlags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtil::IOFile file(full_path, "wb");
|
FileUtil::IOFile file(full_path, "wb");
|
||||||
|
@ -15,7 +15,8 @@ namespace FileSys {
|
|||||||
/// Archive backend for general save data archive type (SaveData and SystemSaveData)
|
/// Archive backend for general save data archive type (SaveData and SystemSaveData)
|
||||||
class SaveDataArchive : public ArchiveBackend {
|
class SaveDataArchive : public ArchiveBackend {
|
||||||
public:
|
public:
|
||||||
explicit SaveDataArchive(const std::string& mount_point_) : mount_point(mount_point_) {}
|
explicit SaveDataArchive(const std::string& mount_point_, bool allow_zero_size_create_ = true)
|
||||||
|
: mount_point(mount_point_), allow_zero_size_create(allow_zero_size_create_) {}
|
||||||
|
|
||||||
std::string GetName() const override {
|
std::string GetName() const override {
|
||||||
return "SaveDataArchive: " + mount_point;
|
return "SaveDataArchive: " + mount_point;
|
||||||
@ -35,6 +36,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string mount_point;
|
std::string mount_point;
|
||||||
|
bool allow_zero_size_create;
|
||||||
SaveDataArchive() = default;
|
SaveDataArchive() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -42,6 +44,7 @@ private:
|
|||||||
void serialize(Archive& ar, const unsigned int) {
|
void serialize(Archive& ar, const unsigned int) {
|
||||||
ar& boost::serialization::base_object<ArchiveBackend>(*this);
|
ar& boost::serialization::base_object<ArchiveBackend>(*this);
|
||||||
ar& mount_point;
|
ar& mount_point;
|
||||||
|
ar& allow_zero_size_create;
|
||||||
}
|
}
|
||||||
friend class boost::serialization::access;
|
friend class boost::serialization::access;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user