Rewritten saveAs using BufferedFile

pull/1/head
Tatsuhiro Tsujikawa 2011-08-07 01:10:17 +09:00
parent a6c2ad53bf
commit 0f349773f5
1 changed files with 7 additions and 5 deletions

View File

@ -81,6 +81,7 @@
#include "Logger.h"
#include "Option.h"
#include "DownloadContext.h"
#include "BufferedFile.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h"
@ -1400,13 +1401,14 @@ bool saveAs
}
std::string tempFilename = strconcat(filename, "__temp");
{
std::ofstream out(tempFilename.c_str(), std::ios::binary);
if(!out) {
BufferedFile fp(tempFilename, BufferedFile::WRITE);
if(!fp) {
return false;
}
out << data;
out.flush();
if(!out) {
if(fp.write(data.data(), data.size()) != data.size()) {
return false;
}
if(fp.close() == EOF) {
return false;
}
}