projects
/
oweals
/
minetest.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Node highlighting.
[oweals/minetest.git]
/
src
/
filesys.cpp
diff --git
a/src/filesys.cpp
b/src/filesys.cpp
index 7c72a4b2757f9f6d7601af372ecc82a77fff6b99..b95986a92bcc9f880a412d1703441ea8549d85b8 100644
(file)
--- a/
src/filesys.cpp
+++ b/
src/filesys.cpp
@@
-701,16
+701,19
@@
bool safeWriteToFile(const std::string &path, const std::string &content)
os << content;
os.flush();
os.close();
os << content;
os.flush();
os.close();
- if (os.fail())
+ if (os.fail()) {
+ remove(tmp_file.c_str());
return false;
return false;
+ }
// Copy file
// Copy file
-#ifdef _WIN32
remove(path.c_str());
remove(path.c_str());
- return (rename(tmp_file.c_str(), path.c_str()) == 0);
-#else
- return (rename(tmp_file.c_str(), path.c_str()) == 0);
-#endif
+ if(rename(tmp_file.c_str(), path.c_str())) {
+ remove(tmp_file.c_str());
+ return false;
+ } else {
+ return true;
+ }
}
} // namespace fs
}
} // namespace fs