aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/TextFile.cxx16
-rw-r--r--src/TextFile.hxx18
2 files changed, 22 insertions, 12 deletions
diff --git a/src/TextFile.cxx b/src/TextFile.cxx
index 4ad59ee4a..da0b33816 100644
--- a/src/TextFile.cxx
+++ b/src/TextFile.cxx
@@ -19,10 +19,26 @@
#include "config.h"
#include "TextFile.hxx"
+#include "fs/Path.hxx"
+#include "fs/FileSystem.hxx"
+
+#include <glib.h>
#include <assert.h>
#include <string.h>
+TextFile::TextFile(const Path &path_fs)
+ :file(FOpen(path_fs, FOpenMode::ReadText)),
+ buffer(g_string_sized_new(step)) {}
+
+TextFile::~TextFile()
+{
+ if (file != nullptr)
+ fclose(file);
+
+ g_string_free(buffer, true);
+}
+
char *
TextFile::ReadLine()
{
diff --git a/src/TextFile.hxx b/src/TextFile.hxx
index d593e0961..6aff4ca70 100644
--- a/src/TextFile.hxx
+++ b/src/TextFile.hxx
@@ -21,10 +21,11 @@
#define MPD_TEXT_FILE_HXX
#include "gcc.h"
-#include "fs/Path.hxx"
-#include "fs/FileSystem.hxx"
-#include <glib.h>
+#include <stdio.h>
+
+class Path;
+typedef struct _GString GString;
class TextFile {
static constexpr size_t max_length = 512 * 1024;
@@ -35,18 +36,11 @@ class TextFile {
GString *const buffer;
public:
- TextFile(const Path &path_fs)
- :file(FOpen(path_fs, FOpenMode::ReadText)),
- buffer(g_string_sized_new(step)) {}
+ TextFile(const Path &path_fs);
TextFile(const TextFile &other) = delete;
- ~TextFile() {
- if (file != nullptr)
- fclose(file);
-
- g_string_free(buffer, true);
- }
+ ~TextFile();
bool HasFailed() const {
return gcc_unlikely(file == nullptr);