mirror of
https://github.com/aria2/aria2.git
synced 2025-04-07 06:27:37 +03:00
2008-09-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented the ability to get timestamp from remote HTTP server and apply it to local file. To enable this feature, --remote-time option is added. No usage text has been written yet. If several servers returns difference timestamp, then aria2 uses latest one. * src/CopyDiskAdaptor.cc * src/CopyDiskAdaptor.h * src/DirectDiskAdaptor.cc * src/DirectDiskAdaptor.h * src/DiskAdaptor.h * src/File.cc * src/File.h * src/HttpHeader.cc * src/HttpHeader.h * src/HttpResponse.cc * src/HttpResponse.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/MultiDiskAdaptor.cc * src/MultiDiskAdaptor.h * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/option_processing.cc * src/prefs.cc * src/prefs.h * test/CopyDiskAdaptorTest.cc * test/FileTest.cc * test/Makefile.am * test/Makefile.in * test/MultiDiskAdaptorTest.cc * test/TestUtil.cc
This commit is contained in:
parent
4e28efd925
commit
dbc8f5b737
29 changed files with 352 additions and 13 deletions
|
@ -1,15 +1,29 @@
|
|||
#include "TestUtil.h"
|
||||
#include "a2io.h"
|
||||
#include "File.h"
|
||||
#include "StringFormat.h"
|
||||
#include "FatalException.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
void createFile(const std::string& path, size_t length)
|
||||
{
|
||||
File(File(path).getDirname()).mkdirs();
|
||||
int fd = creat(path.c_str(), OPEN_MODE);
|
||||
ftruncate(fd, length);
|
||||
if(fd == -1) {
|
||||
throw FatalException(StringFormat("Could not create file=%s. cause:%s",
|
||||
path.c_str(), strerror(errno)).str());
|
||||
}
|
||||
if(-1 == ftruncate(fd, length)) {
|
||||
throw FatalException(StringFormat("ftruncate failed. cause:%s",
|
||||
strerror(errno)).str());
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue