|
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.
|