diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-08-07 01:21:55 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-08-07 01:43:02 +0900 |
| commit | 4220c2aadcc84894e838636ed952a876eb24d1fa (patch) | |
| tree | f00105d06dd7444b602543efc8b59074483ae610 /src/BufferedFile.cc | |
| parent | b3b67f440b286962d3ceb3b8db016c0c33efebf5 (diff) | |
Read aria2.conf using BufferedFile
Read aria2.conf using BufferedFile. Added BufferedFile::transfer().
Diffstat (limited to 'src/BufferedFile.cc')
| -rw-r--r-- | src/BufferedFile.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/BufferedFile.cc b/src/BufferedFile.cc index 078acb27..080d251d 100644 --- a/src/BufferedFile.cc +++ b/src/BufferedFile.cc @@ -35,6 +35,7 @@ #include "BufferedFile.h" #include <cstring> +#include <ostream> #include "a2io.h" #include "util.h" @@ -102,4 +103,19 @@ bool BufferedFile::eof() return open_ && feof(fp_); } +size_t BufferedFile::transfer(std::ostream& out) +{ + size_t count = 0; + char buf[4096]; + while(1) { + size_t r = this->read(buf, sizeof(buf)); + out.write(buf, r); + count += r; + if(r < sizeof(buf)) { + break; + } + } + return count; +} + } // namespace aria2 |
