From aa2e4d92e0005f4516eb591803120eff89f99109 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 7 Aug 2014 18:54:06 +0200 Subject: fs/io/BufferedReader: new class to replace class TextFile The new class is pluggable, to prepare for gzipped database files. For now, the TextFile class remains, and will be refactored away later. --- src/fs/io/TextFile.hxx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/fs/io/TextFile.hxx') diff --git a/src/fs/io/TextFile.hxx b/src/fs/io/TextFile.hxx index e3a712a88..33a1b8060 100644 --- a/src/fs/io/TextFile.hxx +++ b/src/fs/io/TextFile.hxx @@ -22,29 +22,26 @@ #include "Compiler.h" -#include #include class Path; +class Error; +class FileReader; +class BufferedReader; class TextFile { - static constexpr size_t max_length = 512 * 1024; - static constexpr size_t step = 1024; - - FILE *const file; - - char *buffer; - size_t capacity, length; + FileReader *const file_reader; + BufferedReader *const buffered_reader; public: - TextFile(Path path_fs); + TextFile(Path path_fs, Error &error); TextFile(const TextFile &other) = delete; ~TextFile(); bool HasFailed() const { - return gcc_unlikely(file == nullptr); + return gcc_unlikely(buffered_reader == nullptr); } /** @@ -53,7 +50,6 @@ public: * prevent denial of service. * * @param file the source file, opened in text mode - * @param buffer an allocator for the buffer * @return a pointer to the line, or nullptr on end-of-file or error */ char *ReadLine(); -- cgit v1.2.3