diff --git a/libaegisub/common/io.cpp b/libaegisub/common/io.cpp index c95c5559a..c8531120f 100644 --- a/libaegisub/common/io.cpp +++ b/libaegisub/common/io.cpp @@ -32,12 +32,12 @@ namespace agi { std::unique_ptr Open(fs::path const& file, bool binary) { LOG_D("agi/io/open/file") << file; - acs::CheckFileRead(file); auto stream = agi::make_unique(file, (binary ? std::ios::binary : std::ios::in)); - - if (stream->fail()) - throw IOFatal("Unknown fatal error as occurred"); + if (stream->fail()) { + acs::CheckFileRead(file); + throw IOFatal("Unknown fatal error occurred opening " + file.string()); + } return std::unique_ptr(stream.release()); } @@ -47,18 +47,13 @@ Save::Save(fs::path const& file, bool binary) , tmp_name(unique_path(file.parent_path()/(file.stem().string() + "_tmp_%%%%" + file.extension().string()))) { LOG_D("agi/io/save/file") << file; - acs::CheckDirWrite(file.parent_path()); - - try { - acs::CheckFileWrite(file); - } - catch (fs::FileNotFound const&) { - // Not an error - } fp = agi::make_unique(tmp_name, binary ? std::ios::binary : std::ios::out); - if (!fp->good()) + if (!fp->good()) { + acs::CheckDirWrite(file.parent_path()); + acs::CheckFileWrite(file); throw fs::WriteDenied(tmp_name); + } } Save::~Save() {