Go to the documentation of this file.
31 #include <SDL_endian.h>
51 if (is_open ()) gzclose (file);
56 if (t == READ) file = gzopen (fname.c_str (),
"rb6");
57 else file = gzopen (fname.c_str (),
"wb6");
58 if (!file)
return false;
65 if (is_open ()) gzclose (file);
90 gzread (gfile.
file, &b, sizeof (b));
98 gzread (
file, &b,
sizeof (b));
105 gzread (gfile.
file, &n, sizeof (n));
112 gzread (
file, to, size);
118 gzread(gfile.
file, &n, sizeof (n));
126 gzread (
file, &n,
sizeof (n));
133 gzread(gfile.
file, &n, sizeof (n));
141 gzread (
file, &n,
sizeof (n));
148 gzread(gfile.
file, &n, sizeof (n));
157 gzread (
file, &n,
sizeof (n));
158 return SDL_SwapLE16(n);
164 gzread(gfile.
file, &n, sizeof (n));
173 gzread (
file, &n,
sizeof (n));
174 return SDL_SwapLE16(n);
180 gzread(gfile.
file, &n, sizeof (n));
189 gzread (
file, &n,
sizeof (n));
190 return SDL_SwapLE32(n);
196 gzread(gfile.
file, &n, sizeof (n));
205 gzread (
file, &n,
sizeof (n));
206 return SDL_SwapLE32(n);
240 sscanf (sf.c_str (),
"%f", &f);
273 gzwrite (
file, to, size);
280 gzwrite (gfile.
file, &b, sizeof (b));
287 gzwrite (gfile.
file, (
char *) &n, sizeof (n));
294 gzwrite(gfile.
file, (
u_int8 *) &n, sizeof (n));
301 gzwrite(gfile.
file, (
s_int8 *) &n, sizeof (n));
344 for (i = ((
string&) s).begin (); i != ((
string&) s).end (); i++)
355 snprintf (sf, 16,
"%f", f);
376 if (name ==
"") name =
"<unknown>";
381 cerr <<
"Version information missing in file \"" << name << endl;
382 cerr <<
"You should get a more recent data package.\n";
389 if (version < min || version > max)
391 cerr <<
"File \"" << name <<
"\" has\nversion number " << version <<
", ";
392 cerr <<
"but I was expecting " << min <<
" <= version <= " << max << endl;
396 cerr <<
"You should get an up-to-date version of this program.\n\n";
399 cerr <<
"You should probably get a more recent data package.\n";
s_int8 get_sint8()
Reads a s_int8.
Class to read data from a Gzip compressed file.
#define u_int32
32 bits long unsigned integer
void get_block(void *to, u_int32 size)
Reads a block of bytes from the file.
#define s_int32
32 bits long signed integer
igzstream()
Default constructor.
virtual ~gz_file()
Destructor.
gz_file()
Default constructor.
Class to write data from a Gzip compressed file.
#define u_int8
8 bits long unsigned integer
void put_block(void *to, u_int32 size)
Writes a block of bytes to the file.
static void put_version(ogzstream &file, u_int16 version)
Sets the version number of a file.
#define s_int16
16 bits long signed integer
Declares the igzstream, ogzstream and fileops classes.
void close()
Close the file that was opened.
bool get_bool()
Reads a boolean.
gz_type
Enumeration to know whether a file is read or write opened.
#define s_int8
8 bits long signed integer
bool open(const string &fname)
Opens a file for write access.
Base class for igzstream and ogzstream.
u_int8 get_uint8()
Reads a u_int8.
bool open(const string &fname)
Opens a file for read access.
static bool get_version(igzstream &file, u_int16 min, u_int16 max, string name)
const bool & operator>>(const bool &n, ogzstream &gfile)
Writes a boolean.
bool open(const string &fname, gz_type t)
Opens a file.
#define u_int16
16 bits long unsigned integer
string get_string()
Reads a string.
u_int32 get_uint32()
Reads a u_int32.
ogzstream()
Default constructor.
gzFile file
The actual gzFile.
bool & operator<<(bool &n, igzstream &gfile)
Reads a boolean.
s_int16 get_sint16()
Reads a s_int16.
u_int16 get_uint16()
Reads a u_int16.
s_int32 get_sint32()
Reads a s_int32.
float get_float()
Reads a float.