diff options
author | Shravan M Narayanamurthy <shravanm@richbreak-lr.eglbp.corp.yahoo.com> | 2009-12-11 14:57:31 +0300 |
---|---|---|
committer | Shravan M Narayanamurthy <shravanm@richbreak-lr.eglbp.corp.yahoo.com> | 2009-12-11 14:57:31 +0300 |
commit | 6dc15b3c49c3d0d337ae0f0a33cd3a97db0381f6 (patch) | |
tree | 8287c29474ae6d1ee067c3ba19d4e614f7186b1c /main.cc | |
parent | 5e754be6a54af547e2a1389b006c2912dee9eb78 (diff) |
Adding support for compression using zlib/gzip
Abstracted all direct access to opening, closing, resetting, flushing, reading & writing files of io_buf into access through a function of io_buf which have all been declared virtual. Now that these accesses have been abstracted out, adding a new type of io_buf, in this case, comp_io_buf, is pretty easy. Just public inherit io_buf and override the default definitions of these virtual functions to work with compressed files.
There is a nuance in this because of the current use of multiple files. The 'files' v_array is conveniently typed to int. So in the comp_io_buf, I hold a v_array of gzFiles whose indices are stored in 'files' v_array.
Have introduced a new boolean flag compressed into parse_args.
The input & output io_bufs in parser are now just pointers that will point to comp_io_buf if the compressed option is chosen. This is the root cause of most of the changes involving parser::input & parser::output.
Because of the design of zlib which allows gzread to read from a normal file we can read from a mix of compressed and uncompressed files(cache) without extra logic.
Diffstat (limited to 'main.cc')
-rw-r--r-- | main.cc | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -29,7 +29,7 @@ int main(int argc, char *argv[]) { cerr << endl; } - free(vars); + delete vars; return 0; } |