diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-08-07 17:05:50 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-08-07 17:05:50 +0900 |
| commit | b6b8cb005dfb37646e92c4fa9b6805266cdc4632 (patch) | |
| tree | be7535d11c7ad4a08ebcd26426bb039a984b0dc1 /src/BufferedFile.cc | |
| parent | e2d682e0c6f786856946133bc34e2ae5e9ddbd8f (diff) | |
Added printf and flush method to BufferedFile.
Diffstat (limited to 'src/BufferedFile.cc')
| -rw-r--r-- | src/BufferedFile.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/BufferedFile.cc b/src/BufferedFile.cc index 080d251d..812704c9 100644 --- a/src/BufferedFile.cc +++ b/src/BufferedFile.cc @@ -35,6 +35,7 @@ #include "BufferedFile.h" #include <cstring> +#include <cstdarg> #include <ostream> #include "a2io.h" @@ -44,6 +45,7 @@ namespace aria2 { const std::string BufferedFile::READ = "rb"; const std::string BufferedFile::WRITE = "wb"; +const std::string BufferedFile::APPEND = "ab"; BufferedFile::BufferedFile(const std::string& filename, const std::string& mode) { @@ -51,6 +53,10 @@ BufferedFile::BufferedFile(const std::string& filename, const std::string& mode) open_ = fp_; } +BufferedFile::BufferedFile(FILE* fp) + : fp_(fp), open_(true) +{} + BufferedFile::~BufferedFile() { close(); @@ -118,4 +124,18 @@ size_t BufferedFile::transfer(std::ostream& out) return count; } +int BufferedFile::printf(const char* format, ...) +{ + va_list ap; + va_start(ap, format); + int r = vfprintf(fp_, format, ap); + va_end(ap); + return r; +} + +int BufferedFile::flush() +{ + return fflush(fp_); +} + } // namespace aria2 |
