aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/io/TextFile.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-07 18:54:06 +0200
committerMax Kellermann <max@duempel.org>2014-08-07 19:38:25 +0200
commitaa2e4d92e0005f4516eb591803120eff89f99109 (patch)
treebeb83ec24f0cb5b527ec60bd56c2722681f1d3f5 /src/fs/io/TextFile.hxx
parent0ea66a1275da319e2443fa1536cec7ea7fc53b53 (diff)
downloadmpd-aa2e4d92e0005f4516eb591803120eff89f99109.tar.gz
mpd-aa2e4d92e0005f4516eb591803120eff89f99109.tar.xz
mpd-aa2e4d92e0005f4516eb591803120eff89f99109.zip
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.
Diffstat (limited to 'src/fs/io/TextFile.hxx')
-rw-r--r--src/fs/io/TextFile.hxx18
1 files changed, 7 insertions, 11 deletions
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 <stdio.h>
#include <stddef.h>
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();