]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/filesys.rb
exchanged zlib code with commandline gzip
[biopieces.git] / code_ruby / lib / maasha / filesys.rb
index 6a6067fbc859bb3df62a7f4eda547c0f44d8070c..81190f532d6ee54281d85d923168e5fd703c51fe 100644 (file)
@@ -22,8 +22,9 @@
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
-require 'zlib'
-require 'bzip2'
+# require 'zlib'
+# require 'bzip2'
+require 'open3'
 
 # Error class for all exceptions to do with Filesys.
 class FilesysError < StandardError; end
@@ -49,9 +50,11 @@ 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)
+        # ios = Bzip2::Writer.new File.open(file, mode, options)   # TODO being pissed with buggy bzip2 gem.
+        ios, = Open3.pipeline_w("bzip2 -c", out: file)
       else 
         ios = File.open(file, mode, options)
       end
@@ -59,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("zcat #{file}")
         when /bzip/
           # ios = Bzip2::Reader.new File.open(file, mode, options)   # TODO this method is buggy, investigate
           ios = IO.popen("bzcat #{file}")