TextFile: don't include glib.h in header
Un-inline the methods that use GLib.
This commit is contained in:
parent
43675717b8
commit
c53492a76a
@ -19,10 +19,26 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "TextFile.hxx"
|
#include "TextFile.hxx"
|
||||||
|
#include "fs/Path.hxx"
|
||||||
|
#include "fs/FileSystem.hxx"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.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 *
|
char *
|
||||||
TextFile::ReadLine()
|
TextFile::ReadLine()
|
||||||
{
|
{
|
||||||
|
@ -21,10 +21,11 @@
|
|||||||
#define MPD_TEXT_FILE_HXX
|
#define MPD_TEXT_FILE_HXX
|
||||||
|
|
||||||
#include "gcc.h"
|
#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 {
|
class TextFile {
|
||||||
static constexpr size_t max_length = 512 * 1024;
|
static constexpr size_t max_length = 512 * 1024;
|
||||||
@ -35,18 +36,11 @@ class TextFile {
|
|||||||
GString *const buffer;
|
GString *const buffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextFile(const Path &path_fs)
|
TextFile(const Path &path_fs);
|
||||||
:file(FOpen(path_fs, FOpenMode::ReadText)),
|
|
||||||
buffer(g_string_sized_new(step)) {}
|
|
||||||
|
|
||||||
TextFile(const TextFile &other) = delete;
|
TextFile(const TextFile &other) = delete;
|
||||||
|
|
||||||
~TextFile() {
|
~TextFile();
|
||||||
if (file != nullptr)
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
g_string_free(buffer, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HasFailed() const {
|
bool HasFailed() const {
|
||||||
return gcc_unlikely(file == nullptr);
|
return gcc_unlikely(file == nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user