mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 02:36: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) {
|
const WriteFunction& _write) {
|
||||||
try {
|
try {
|
||||||
std::ofstream output(_fname, std::ios::out | std::ios::binary);
|
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);
|
_write(_obj, output);
|
||||||
output.close();
|
output.close();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ Result<Nothing> save_string(const std::string& _fname, const T& _obj,
|
|||||||
try {
|
try {
|
||||||
std::ofstream outfile;
|
std::ofstream outfile;
|
||||||
outfile.open(_fname);
|
outfile.open(_fname);
|
||||||
|
if (!outfile.is_open()) {
|
||||||
|
return error("Unable to open file '" + _fname + "' for writing.");
|
||||||
|
}
|
||||||
_write(_obj, outfile);
|
_write(_obj, outfile);
|
||||||
outfile.close();
|
outfile.close();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user