|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
44 # if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
49 #endif // GENESIS_ZLIB
62 bool const ext_gz = ( ext ==
"gz" || ext ==
"gzip" );
66 infile.open( file_name, std::ifstream::in | std::ifstream::binary );
67 if( !infile.good() ) {
73 unsigned char buffer[2];
74 infile.read(
reinterpret_cast<char*
>( &buffer ), 2 );
75 if( !infile.good() ) {
81 bool const magic = ( buffer[0] == 0x1f ) && ( buffer[1] == 0x8b );
85 if( ext_gz && magic ) {
87 }
else if( ! ext_gz && ! magic ) {
89 }
else if( ext_gz && ! magic ) {
90 LOG_WARN <<
"File name '" << file_name <<
"' ends in '.gz', but the file does not seem "
91 <<
"to contain gzip content.";
92 }
else if( ! ext_gz && magic ) {
93 LOG_WARN <<
"File name '" << file_name <<
"' does not end in '.gz', but the file seems "
94 <<
"to contain gzip content.";
118 message_ +=
"Invalid compression level. [Z_STREAM_ERROR: ";
121 message_ +=
"Invalid or incomplete deflate data. [Z_DATA_ERROR: ";
124 message_ +=
"Out of memory. [Z_MEM_ERROR: ";
126 case Z_VERSION_ERROR:
127 message_ +=
"Version mismatch! [Z_VERSION_ERROR: ";
130 message_ +=
"Buffer error. [Z_BUF_ERROR: ";
133 message_ +=
"Error while reading zlib/gzip input. [Z_ERRNO: ";
142 #else // GENESIS_ZLIB
147 message_ =
"zlib: Genesis was not compiled with zlib support.";
150 #endif // GENESIS_ZLIB
GzipError(std::string const &z_stream_message, int error_code)
Provides functions for accessing the file system.
std::string to_string(GenomeLocus const &locus)
#define LOG_WARN
Log a warning. See genesis::utils::LoggingLevel.
Provides easy and fast logging functionality.
bool is_gzip_compressed_file(std::string const &file_name)
Return whether a given file is gzip-compressed.
Exception class for general input/output errors.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
std::string file_extension(std::string const &filename)
Return the extension name of a file.