mirror of https://github.com/aria2/aria2
2010-04-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Ensure that std::ofstream is destroyed before renaming. * src/SessionSerializer.cc * src/util.ccpull/1/head
parent
c415eb081e
commit
aa08af9928
|
@ -1,3 +1,9 @@
|
||||||
|
2010-04-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Ensure that std::ofstream is destroyed before renaming.
|
||||||
|
* src/SessionSerializer.cc
|
||||||
|
* src/util.cc
|
||||||
|
|
||||||
2010-04-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-04-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Fixed the bug that user specified path is escaped using
|
Fixed the bug that user specified path is escaped using
|
||||||
|
|
|
@ -62,14 +62,16 @@ SessionSerializer::SessionSerializer
|
||||||
bool SessionSerializer::save(const std::string& filename) const
|
bool SessionSerializer::save(const std::string& filename) const
|
||||||
{
|
{
|
||||||
std::string tempFilename = strconcat(filename, "__temp");
|
std::string tempFilename = strconcat(filename, "__temp");
|
||||||
std::ofstream out(tempFilename.c_str(), std::ios::binary);
|
{
|
||||||
if(!out) {
|
std::ofstream out(tempFilename.c_str(), std::ios::binary);
|
||||||
return false;
|
if(!out) {
|
||||||
}
|
return false;
|
||||||
save(out);
|
}
|
||||||
out.flush();
|
save(out);
|
||||||
if(!out) {
|
out.flush();
|
||||||
return false;
|
if(!out) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return File(tempFilename).renameTo(filename);
|
return File(tempFilename).renameTo(filename);
|
||||||
}
|
}
|
||||||
|
|
18
src/util.cc
18
src/util.cc
|
@ -1147,14 +1147,16 @@ bool saveAs
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string tempFilename = strconcat(filename, "__temp");
|
std::string tempFilename = strconcat(filename, "__temp");
|
||||||
std::ofstream out(tempFilename.c_str(), std::ios::binary);
|
{
|
||||||
if(!out) {
|
std::ofstream out(tempFilename.c_str(), std::ios::binary);
|
||||||
return false;
|
if(!out) {
|
||||||
}
|
return false;
|
||||||
out << data;
|
}
|
||||||
out.flush();
|
out << data;
|
||||||
if(!out) {
|
out.flush();
|
||||||
return false;
|
if(!out) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return File(tempFilename).renameTo(filename);
|
return File(tempFilename).renameTo(filename);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue