mirror of https://github.com/aria2/aria2
2008-10-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use seek() and SetEndOfFile() for mingw32 build instead of ftruncate(), because mingw32's ftruncate() cannot handle more than 2GB-size file. * src/AbstractDiskWriter.ccpull/1/head
parent
c682371a58
commit
859193c50b
|
@ -1,3 +1,9 @@
|
||||||
|
2008-10-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Use seek() and SetEndOfFile() for mingw32 build instead of ftruncate(),
|
||||||
|
because mingw32's ftruncate() cannot handle more than 2GB-size file.
|
||||||
|
* src/AbstractDiskWriter.cc
|
||||||
|
|
||||||
2008-10-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-10-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Don't set Request::supportsPersistentConnection() in HttpConnection
|
Don't set Request::supportsPersistentConnection() in HttpConnection
|
||||||
|
|
|
@ -33,6 +33,17 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "AbstractDiskWriter.h"
|
#include "AbstractDiskWriter.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
# include <windows.h>
|
||||||
|
#endif // __MINGW32__
|
||||||
|
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
@ -42,9 +53,6 @@
|
||||||
#include "a2io.h"
|
#include "a2io.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
#include "DownloadFailureException.h"
|
#include "DownloadFailureException.h"
|
||||||
#include <cerrno>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -159,7 +167,21 @@ void AbstractDiskWriter::truncate(uint64_t length)
|
||||||
if(fd == -1) {
|
if(fd == -1) {
|
||||||
throw DlAbortEx("File not opened.");
|
throw DlAbortEx("File not opened.");
|
||||||
}
|
}
|
||||||
ftruncate(fd, length);
|
#ifdef __MINGW32__
|
||||||
|
// Since mingw32's ftruncate cannot handle over 2GB files, we use SetEndOfFile
|
||||||
|
// instead.
|
||||||
|
HANDLE handle = LongToHandle(_get_osfhandle(fd));
|
||||||
|
seek(length);
|
||||||
|
if(SetEndOfFile(handle) == 0) {
|
||||||
|
throw DlAbortEx(StringFormat("SetEndOfFile failed. cause: %s",
|
||||||
|
GetLastError()).str());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if(ftruncate(fd, length) == -1) {
|
||||||
|
throw DlAbortEx(StringFormat("ftruncate failed. cause: %s",
|
||||||
|
strerror(errno)).str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO the file descriptor fd must be opened before calling this function.
|
// TODO the file descriptor fd must be opened before calling this function.
|
||||||
|
|
Loading…
Reference in New Issue