mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 13:37:40 +03:00
Introduce IOFile abstract class to refactor BufferedFile and GZipFile
IOFile provides the same interface of old BufferedFile. It provides extension points as pure virtual functions. Those functions are implemented by 2 concrete subclasses: BufferedFile and GZipFile.
This commit is contained in:
parent
6c0fa43fa5
commit
b0799b6e46
12 changed files with 343 additions and 154 deletions
|
@ -24,16 +24,16 @@ void BufferedFileTest::testOpen()
|
|||
{
|
||||
File f(A2_TEST_OUT_DIR"/aria2_BufferedFileTest_testOpen");
|
||||
f.remove();
|
||||
BufferedFile fail(f.getPath().c_str(), BufferedFile::READ);
|
||||
BufferedFile fail(f.getPath().c_str(), IOFile::READ);
|
||||
CPPUNIT_ASSERT(!fail);
|
||||
|
||||
BufferedFile wr(f.getPath().c_str(), BufferedFile::WRITE);
|
||||
BufferedFile wr(f.getPath().c_str(), IOFile::WRITE);
|
||||
CPPUNIT_ASSERT(wr);
|
||||
std::string msg = "aria2 rules\nalpha\nbravo\ncharlie";
|
||||
wr.write(msg.data(), msg.size());
|
||||
wr.close();
|
||||
|
||||
BufferedFile rd(f.getPath().c_str(), BufferedFile::READ);
|
||||
BufferedFile rd(f.getPath().c_str(), IOFile::READ);
|
||||
char buf[256];
|
||||
size_t len = rd.read(buf, 11);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)11, len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue