[cig-commits] r16273 - cs/stats/trunk

sue at geodynamics.org sue at geodynamics.org
Wed Feb 17 09:15:23 PST 2010


Author: sue
Date: 2010-02-17 09:15:22 -0800 (Wed, 17 Feb 2010)
New Revision: 16273

Modified:
   cs/stats/trunk/Makefile
   cs/stats/trunk/get_all.cxx
Log:
Read the compressed log files directly instead of copying and uncompressing with gzip

Modified: cs/stats/trunk/Makefile
===================================================================
--- cs/stats/trunk/Makefile	2010-02-17 14:42:19 UTC (rev 16272)
+++ cs/stats/trunk/Makefile	2010-02-17 17:15:22 UTC (rev 16273)
@@ -1,2 +1,2 @@
 get_all: get_all.cxx
-	g++ -O3 get_all.cxx -o get_all -lboost_filesystem
+	g++ -O3 get_all.cxx -o get_all -lboost_filesystem -lz -lboost_iostreams

Modified: cs/stats/trunk/get_all.cxx
===================================================================
--- cs/stats/trunk/get_all.cxx	2010-02-17 14:42:19 UTC (rev 16272)
+++ cs/stats/trunk/get_all.cxx	2010-02-17 17:15:22 UTC (rev 16273)
@@ -7,6 +7,8 @@
 #include <iostream>
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/fstream.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
+#include <boost/iostreams/filter/gzip.hpp>
 
 using namespace std;
 namespace fs=boost::filesystem;
@@ -262,26 +264,12 @@
     {
       unsigned int size(log_path->leaf().size());
       
-      fs::path file_path(*log_path);
-      string temp_file("temp_file");
+      fs::ifstream file(*log_path, ios_base::in | ios_base::binary);
+      boost::iostreams::filtering_istream log;
       if(size>3 && log_path->leaf().substr(size-3)==".gz")
-	{
-	  string temp_file_gz("temp_file.gz");
-	  fs::remove(temp_file_gz);
-	  fs::remove(temp_file);
-	  fs::copy_file(*log_path,temp_file_gz);
-	  if(system(("gunzip " + temp_file_gz).c_str()))
-	    {
-	      cerr << "Can not uncompress temp file for "
-		   << log_path->string() << "\n";
-	      abort();
-	    }
-	  file_path=temp_file;
-	}
-//       cout << log_path->string() << "\t"
-// 	   << file_path.string() << "\n";
+        log.push(boost::iostreams::gzip_decompressor());
+      log.push(file);
       
-      fs::ifstream log(file_path);
       while(log)
 	{
 	  log.getline(line,max_size);
@@ -331,7 +319,6 @@
 			}
 		  }
 	}
-      fs::remove(temp_file);
     }
 
   for(set<string>::iterator i=robots.begin(); i!=robots.end(); ++i)



More information about the CIG-COMMITS mailing list