[pan2] improved tmp file handling with finailze_ostream
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2] improved tmp file handling with finailze_ostream
- Date: Mon, 18 Jun 2012 16:45:58 +0000 (UTC)
commit e6ad0bb5dc4b777088d708624cb428812144dcfe
Author: Heinrich MÃller <henmull src gnome org>
Date: Mon Jun 18 18:26:23 2012 +0200
improved tmp file handling with finailze_ostream
pan/data-impl/data-io.cc | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/pan/data-impl/data-io.cc b/pan/data-impl/data-io.cc
index 56127bf..17398b2 100644
--- a/pan/data-impl/data-io.cc
+++ b/pan/data-impl/data-io.cc
@@ -202,14 +202,19 @@ namespace
const std::string tmpfile (filename + ".tmp");
if (ok) {
-// ::remove (filename.c_str()); not needed
- if (rename (tmpfile.c_str(), filename.c_str()))
- std::cerr << LINE_ID << " ERROR renaming from [" << tmpfile << "] to [" << filename << "]: " << g_strerror(errno) << '\n';
- if (chmod (filename.c_str(), 0600))
- std::cerr << LINE_ID << " ERROR chmodding [" << filename << "]: " << g_strerror(errno) << '\n';
+ remove (filename.c_str());
+ int ret = 0;
+ if ((ret = rename (tmpfile.c_str(), filename.c_str())))
+ {
+ std::cerr << LINE_ID << " ERROR renaming from [" << tmpfile << "] to [" << filename << "]: " << g_strerror(errno) <<" : "<<ret<< '\n';
+ } else
+ {
+ if ((ret = chmod (filename.c_str(), 0600)))
+ std::cerr << LINE_ID << " ERROR chmodding [" << filename << "]: " << g_strerror(errno) << " : "<<ret<<'\n';
+ }
+// std::cerr<<"dbg "<<ret<<"\n";
} else {
Log::add_err_va (_("Unable to save \"%s\" %s"), filename.c_str(), file::pan_strerror(my_errno));
- ::remove (tmpfile.c_str());
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]