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:
Tatsuhiro Tsujikawa 2013-05-23 23:12:32 +09:00
parent 6c0fa43fa5
commit b0799b6e46
12 changed files with 343 additions and 154 deletions

View file

@ -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);