mirror of https://github.com/aria2/aria2
Rewritten saveAs using BufferedFile
parent
a6c2ad53bf
commit
0f349773f5
12
src/util.cc
12
src/util.cc
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue