#include <file_detect.h>
Really nasty hack. This works by copying the file to a temporary file in /tmp and then uncompressing it using a call to system
("gunzip /tmp/filename") . When the file is closed, the temporary file is removed using 'rm -f'.
If the filename ends with ".gz" or ".bz2", then input_detect will try to uncompress it (using gunzip or bunzip2), otherwise, the file will be treated as normal.
Note that there must be enough disk space in the temporary directory for the uncompressed file or the read will fail.
Definition at line 57 of file file_detect.h.
Public Member Functions | |
virtual | ~file_detect () |
in_file_format * | open (const char *s) |
Open an input file with the given name. | |
virtual int | close () |
Close an input file. | |
virtual bool | is_compressed () |
Return true if the opened file was originally compressed. | |
virtual bool | is_binary () |
Return true if the opened file was a binary file. | |
Protected Attributes | |
std::string | temp_filename |
The temporary filename. | |
std::string | user_filename |
The user-supplied filename. | |
in_file_format * | iffp |
The input file. | |
bool | compressed |
True if the file was compressed. | |
bool | binary |
True if the file was a binary file. |
in_file_format* open | ( | const char * | s | ) |
Open an input file with the given name.
If the filename ends with ".gz" or ".bz2", then the file is assumed to be compressed.
It is important to note that the file is not closed until file_detect::close() method is called.