Add support for bzip2 compressed trace files.
authorTom Hughes <tom@compton.nu>
Mon, 18 Jun 2007 12:31:47 +0000 (12:31 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 18 Jun 2007 12:31:47 +0000 (12:31 +0000)
app/models/trace.rb

index 97dcf963518327c516f8b607d733d7819a2c798a..f2dcf9ad9391902c10d81219094abb2c33b2f6c5 100644 (file)
@@ -92,11 +92,15 @@ class Trace < ActiveRecord::Base
       # TODO *nix specific, could do to work on windows... would be functionally inferior though - check for '.gz'
       filetype = `file -b #{trace_name}`.chomp
       gzipped = filetype =~ /^gzip/
+      bzipped = filetype =~ /^bzip2/
       zipped = filetype =~ /^Zip/
 
       if gzipped
         filename = tempfile = "/tmp/#{rand}"
         system("gunzip -c #{trace_name} > #{filename}")
+      elsif bzipped
+        filename = tempfile = "/tmp/#{rand}"
+        system("bunzip2 -c #{trace_name} > #{filename}")
       elsif zipped
         filename = tempfile = "/tmp/#{rand}"
         system("unzip -p #{trace_name} > #{filename}")