mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-11-27 05:16:18 +08:00
This commit is contained in:
@@ -15,6 +15,9 @@ Result<Nothing> save_bytes(const std::string& _fname, const T& _obj,
|
||||
const WriteFunction& _write) {
|
||||
try {
|
||||
std::ofstream output(_fname, std::ios::out | std::ios::binary);
|
||||
if (!output.is_open()) {
|
||||
return error("Unable to open file '" + _fname + "' for writing.");
|
||||
}
|
||||
_write(_obj, output);
|
||||
output.close();
|
||||
} catch (std::exception& e) {
|
||||
|
||||
@@ -15,6 +15,9 @@ Result<Nothing> save_string(const std::string& _fname, const T& _obj,
|
||||
try {
|
||||
std::ofstream outfile;
|
||||
outfile.open(_fname);
|
||||
if (!outfile.is_open()) {
|
||||
return error("Unable to open file '" + _fname + "' for writing.");
|
||||
}
|
||||
_write(_obj, outfile);
|
||||
outfile.close();
|
||||
} catch (std::exception& e) {
|
||||
|
||||
Reference in New Issue
Block a user