summaryrefslogtreecommitdiff
path: root/src/BufferedFile.h
diff options
context:
space:
mode:
authorNils Maier <maierman@web.de>2013-03-01 16:07:16 +0100
committerNils Maier <maierman@web.de>2013-03-02 15:48:26 +0100
commitf2f8b14047c5b0f3a41338440c63ca3f9a591427 (patch)
tree06aeb2584b0d6e1db79b15acadb6612a9af2b590 /src/BufferedFile.h
parentb0556a7519af611f665ee5a6ccc1b514a0585bef (diff)
Support for gzipped -i and --save-session
Saved sessions may very large, as in hundreds and even thousands of megabyte when dealing with large queues. Add support to save and reload sessions to gzipped files, when libz is available. The session serializer will output gzipped contents when the file ends with .gz, while the input file reader (UriListParser) will accept whatever is thrown at it.
Diffstat (limited to 'src/BufferedFile.h')
-rw-r--r--src/BufferedFile.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/BufferedFile.h b/src/BufferedFile.h
index f0d78e07..7eb6a36d 100644
--- a/src/BufferedFile.h
+++ b/src/BufferedFile.h
@@ -56,18 +56,18 @@ public:
// returns false.
operator unspecified_bool_type() const;
// wrapper for fread. Using 1 for 2nd argument of fread.
- size_t read(void* ptr, size_t count);
+ virtual size_t read(void* ptr, size_t count);
// wrapper for fwrite. Using 1 for 2nd argument of fwrite.
- size_t write(const void* ptr, size_t count);
+ virtual size_t write(const void* ptr, size_t count);
virtual size_t write(const char* str);
// wrapper for fgets
- char* gets(char* s, int size);
+ virtual char* gets(char* s, int size);
// wrapper for fgets, but trailing '\n' is replaced with '\0'.
char* getsn(char* s, int size);
// Reads one line and returns it. The last '\n' is removed.
std::string getLine();
// wrapper for fclose
- int close();
+ virtual int close();
// Return true if open_ && feof(fp_) != 0. Otherwise returns false.
bool eof();
// Convenient method. Read data to end of file and write them into
@@ -83,15 +83,21 @@ public:
static const char WRITE[];
// Mode for append
static const char APPEND[];
+
private:
// Don't allow copying
BufferedFile(const BufferedFile&);
BufferedFile& operator=(const BufferedFile&);
FILE* fp_;
- // true when file has been opened.
bool open_;
bool supportsColor_;
+
+protected:
+ virtual bool isError() const { return ferror(fp_); }
+ virtual bool isEOF() const { return feof(fp_); }
+ virtual bool isOpen() const { return open_; }
+
};
} // namespace aria2