]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/filesys.rb
gzip fiddling
[biopieces.git] / code_ruby / lib / maasha / filesys.rb
index 4f58898b91977a3dbc1695ed3191018b316bc34e..eadb53649e785a4144e82f63a3b607e2b314d49e 100644 (file)
@@ -22,7 +22,7 @@
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
-require 'zlib'
+require 'zlib'
 # require 'bzip2'
 require 'open3'
 
@@ -50,7 +50,8 @@ class Filesys
     if mode == 'w'
       case options[:compress]
       when :gzip
-        ios = Zlib::GzipWriter.new File.open(file, mode, options)
+        # ios = Zlib::GzipWriter.new File.open(file, mode, options)
+        ios, = Open3.pipeline_w("gzip -f", out: file)
       when :bzip, :bzip2
         # ios = Bzip2::Writer.new File.open(file, mode, options)   # TODO being pissed with buggy bzip2 gem.
         ios, = Open3.pipeline_w("bzip2 -c", out: file)
@@ -61,9 +62,10 @@ class Filesys
       if file == '-'
         ios = STDIN
       else
-        case `file #{file}`
+        case `file -L #{file}`
         when /gzip/
-          ios = Zlib::GzipReader.new File.open(file, mode, options)
+          # ios = Zlib::GzipReader.new File.open(file, mode, options)
+          ios = IO.popen("gzip -cd #{file}")
         when /bzip/
           # ios = Bzip2::Reader.new File.open(file, mode, options)   # TODO this method is buggy, investigate
           ios = IO.popen("bzcat #{file}")