Code improvements
This commit is contained in:
parent
4ae6cba3ce
commit
73545dd287
|
@ -150,7 +150,7 @@ private:
|
|||
* log_field_ids
|
||||
* 99: warning,
|
||||
* 1: year, 2: month, 3: day, 4: hour, 5: minute, 6:second,
|
||||
* 10: request_protocol, 11: request_method, 12: request_page, 13: request_query, 14: response_code,
|
||||
* 10: request_protocol, 11: request_method, 12: request_uri, 13: request_query, 14: response_code,
|
||||
* 15: time_taken, 16: bytes_sent, 17: bytes_received, 18: referrer,
|
||||
* 20: client, 21: user_agent, 22: cookie
|
||||
*/
|
||||
|
|
|
@ -109,93 +109,9 @@ void GZutils::readFile( const std::string& path, std::string& content )
|
|||
}
|
||||
if ( content.size() == 0 ) {
|
||||
// probably not a gzip compressed file
|
||||
throw("");
|
||||
throw(""); // do not implement
|
||||
}
|
||||
if ( successful == false ) {
|
||||
content = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*const bool GzipOps::readFile( const std::string& path, std::string& content )
|
||||
{
|
||||
bool successful = true;
|
||||
|
||||
FILE * file;
|
||||
z_stream strm = {0};
|
||||
unsigned char in[CHUNK];
|
||||
unsigned char out[CHUNK];
|
||||
|
||||
int windowBits = 15;
|
||||
int ENABLE_ZLIB_GZIP = 32;
|
||||
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
strm.opaque = Z_NULL;
|
||||
strm.next_in = in;
|
||||
strm.avail_in = 0;
|
||||
if ( inflateInit2 (& strm, windowBits | ENABLE_ZLIB_GZIP) < 0 ) {
|
||||
std::cout << "err 1" << std::endl;
|
||||
successful = false;
|
||||
}
|
||||
|
||||
if ( successful == true ) {
|
||||
// open the file
|
||||
file = fopen ( path.c_str(), "rb");
|
||||
if ( !file ) {
|
||||
std::cout << "err opening" << std::endl;
|
||||
successful = false;
|
||||
}
|
||||
if ( successful == true ) {
|
||||
while (true) {
|
||||
int bytes_read;
|
||||
int zlib_status;
|
||||
|
||||
bytes_read = fread (in, sizeof (char), sizeof (in), file);
|
||||
if ( ferror(file) ) {
|
||||
std::cout << "err reading" << std::endl;
|
||||
successful = false;
|
||||
break;
|
||||
}
|
||||
strm.avail_in = bytes_read;
|
||||
strm.next_in = in;
|
||||
do {
|
||||
unsigned have;
|
||||
strm.avail_out = CHUNK;
|
||||
strm.next_out = out;
|
||||
zlib_status = inflate (& strm, Z_NO_FLUSH);
|
||||
switch (zlib_status) {
|
||||
case Z_OK:
|
||||
case Z_STREAM_END:
|
||||
std::cout << "ok" << std::endl;
|
||||
break;
|
||||
case Z_BUF_ERROR:
|
||||
std::cout << "buffer error" << std::endl;
|
||||
successful = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
inflateEnd (& strm);
|
||||
std::cout << "gzip error" << std::endl;
|
||||
successful = false;
|
||||
break;
|
||||
}
|
||||
have = CHUNK - strm.avail_out;
|
||||
fwrite (out, sizeof (unsigned char), have, stdout);
|
||||
}
|
||||
while (strm.avail_out == 0);
|
||||
if (feof (file)) {
|
||||
inflateEnd (& strm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( fclose( file ) ) {
|
||||
std::cout << "err closing" << std::endl;
|
||||
throw("");
|
||||
}
|
||||
|
||||
return successful;
|
||||
}*/
|
||||
|
|
|
@ -195,7 +195,7 @@ void IOutils::randomLines(const std::string& path, std::vector<std::string>& lin
|
|||
if ( file.is_open() ) {
|
||||
file.close();
|
||||
}
|
||||
throw std::exception();
|
||||
throw std::exception(); // exception catched in Craplog
|
||||
}
|
||||
if ( file.is_open() ) {
|
||||
file.close();
|
||||
|
@ -235,7 +235,7 @@ void IOutils::readFile( const std::string& path , std::string& content )
|
|||
if ( file.is_open() == true ) {
|
||||
file.close();
|
||||
}
|
||||
throw std::exception();
|
||||
throw std::exception(); // already catched
|
||||
}
|
||||
|
||||
if ( file.is_open() == true ) {
|
||||
|
@ -271,7 +271,7 @@ void IOutils::writeOnFile( const std::string& path, const std::string& content )
|
|||
if ( file.is_open() == true ) {
|
||||
file.close();
|
||||
}
|
||||
throw std::exception();
|
||||
throw std::exception(); // already catched
|
||||
}
|
||||
|
||||
if ( file.is_open() == true ) {
|
||||
|
|
Loading…
Reference in New Issue