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