42 GZ (
const std::string& fname,
const char* mode) :
gz (NULL) {
54 const std::string&
name ()
const {
58 void open (
const std::string& fname,
const char* mode) {
62 throw Exception (
"cannot access file \"" +
filename +
"\": No such file or directory");
95 z_off_t pos = gzseek (
gz,
offset, SEEK_SET);
102 int n_read = gzread (
gz, s, n);
108 void write (
const char* s,
size_t n) {
110 if (gzwrite (
gz, s, n) <= 0)
116 if (gzputs (
gz, s.c_str()) < 0)
133 if (
string.size() && (
string[
string.size()-1] == 015 ||
string[
string.size()-1] ==
'\n'))
134 string.resize (
string.size()-1);
138 template <
typename T> T
get () {
140 if (
read (&val,
sizeof (T)) !=
sizeof (T))
150 template <
typename T> T*
get (T* buf,
size_t n) {
151 if (
read (buf, n*
sizeof (T)) != n*
sizeof (T))
156 template <
typename T> T*
get (int64_t
offset, T* buf,
size_t n) {
158 return get<T> (buf, n);
167 const char* s = gzerror (
gz, &error_number);
168 if (error_number == Z_ERRNO) s = strerror (errno);
int read(char *s, size_t n)
GZ(const std::string &fname, const char *mode)
void seek(int64_t offset)
void open(const std::string &fname, const char *mode)
void write(const char *s, size_t n)
void write(const std::string &s)
T * get(T *buf, size_t n)
T * get(int64_t offset, T *buf, size_t n)
const std::string & name() const
bool exists(const std::string &path)