fs/io/TextFile: use AutoGunzipReader
Several MPD subsystems can now read gzipped files; for example, the database file can be gzipped.
This commit is contained in:
parent
88a2f128ec
commit
486b5b6bfc
|
@ -20,6 +20,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "TextFile.hxx"
|
#include "TextFile.hxx"
|
||||||
#include "FileReader.hxx"
|
#include "FileReader.hxx"
|
||||||
|
#include "AutoGunzipReader.hxx"
|
||||||
#include "BufferedReader.hxx"
|
#include "BufferedReader.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
|
|
||||||
|
@ -27,8 +28,19 @@
|
||||||
|
|
||||||
TextFile::TextFile(Path path_fs, Error &error)
|
TextFile::TextFile(Path path_fs, Error &error)
|
||||||
:file_reader(new FileReader(path_fs, error)),
|
:file_reader(new FileReader(path_fs, error)),
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
gunzip_reader(file_reader->IsDefined()
|
||||||
|
? new AutoGunzipReader(*file_reader)
|
||||||
|
: nullptr),
|
||||||
|
#endif
|
||||||
buffered_reader(file_reader->IsDefined()
|
buffered_reader(file_reader->IsDefined()
|
||||||
? new BufferedReader(*file_reader)
|
? new BufferedReader(*
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
gunzip_reader
|
||||||
|
#else
|
||||||
|
file_reader
|
||||||
|
#endif
|
||||||
|
)
|
||||||
: nullptr)
|
: nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -36,6 +48,9 @@ TextFile::TextFile(Path path_fs, Error &error)
|
||||||
TextFile::~TextFile()
|
TextFile::~TextFile()
|
||||||
{
|
{
|
||||||
delete buffered_reader;
|
delete buffered_reader;
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
delete gunzip_reader;
|
||||||
|
#endif
|
||||||
delete file_reader;
|
delete file_reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#ifndef MPD_TEXT_FILE_HXX
|
#ifndef MPD_TEXT_FILE_HXX
|
||||||
#define MPD_TEXT_FILE_HXX
|
#define MPD_TEXT_FILE_HXX
|
||||||
|
|
||||||
|
#include "check.h"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -27,10 +28,16 @@
|
||||||
class Path;
|
class Path;
|
||||||
class Error;
|
class Error;
|
||||||
class FileReader;
|
class FileReader;
|
||||||
|
class AutoGunzipReader;
|
||||||
class BufferedReader;
|
class BufferedReader;
|
||||||
|
|
||||||
class TextFile {
|
class TextFile {
|
||||||
FileReader *const file_reader;
|
FileReader *const file_reader;
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
AutoGunzipReader *const gunzip_reader;
|
||||||
|
#endif
|
||||||
|
|
||||||
BufferedReader *const buffered_reader;
|
BufferedReader *const buffered_reader;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue