mirror of
https://github.com/aria2/aria2.git
synced 2026-04-02 18:59:20 +00:00
Added direct I/O support. The current implementation uses O_DIRECT,
which is not posix standard and is tested on linux 2.6.21.
Currently only file allocation uses direct I/O.
* src/SingleFileAllocationIterator.{h, cc}
* test/SingleFileAllocationIteratorTest.cc
* src/MultiFileAllocationIterator.{h, cc}
* test/MultiFileAllocationIteratorTest.cc
* src/BinaryStream.h
* src/DiskWriter.h
* src/AbstractDiskWriter.{h, cc}
* src/ByteArrayDiskWriter.h
* src/DiskAdaptor.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/FileAllocationEntry.cc
* src/Util.{h, cc}
* src/OptionHandlerFactory.cc
* src/prefs.h
* src/version_usage.cc
* src/option_processing.cc
Moved FileAllocationMan::markCurrentFileAllocationEntryDone() to
handleException.
* src/MultiFileAllocationIterator.cc
Added EINTR handling
* src/SocketCore.cc
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#include "SingleFileAllocationIterator.h"
|
|
#include "File.h"
|
|
#include "DefaultDiskWriter.h"
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <fstream>
|
|
#include <iomanip>
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
class SingleFileAllocationIteratorTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(SingleFileAllocationIteratorTest);
|
|
CPPUNIT_TEST(testAllocate);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
|
|
public:
|
|
void setUp() {}
|
|
|
|
void testAllocate();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( SingleFileAllocationIteratorTest );
|
|
|
|
void SingleFileAllocationIteratorTest::testAllocate()
|
|
{
|
|
string dir = "/tmp";
|
|
string fname = "aria2_SingleFileAllocationIteratorTest_testAllocate";
|
|
string fn = dir+"/"+fname;
|
|
ofstream of(fn.c_str());
|
|
of << "0123456789";
|
|
of.close();
|
|
|
|
File x(fn);
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)10, x.size());
|
|
|
|
DefaultDiskWriter writer;
|
|
int64_t offset = 10;
|
|
int64_t totalLength = 16*1024*2+8*1024;
|
|
|
|
// we have to open file first.
|
|
writer.openExistingFile(fn);
|
|
SingleFileAllocationIterator itr(&writer, offset, totalLength);
|
|
itr.init();
|
|
|
|
while(!itr.finished()) {
|
|
itr.allocateChunk();
|
|
}
|
|
File f(fn);
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)40960, f.size());
|
|
}
|