lib/DSK.rb in dsktool-0.1.2 vs lib/DSK.rb in dsktool-0.1.3

- old
+ new

@@ -1,7 +1,8 @@ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) +require 'open-uri' # # For manipulating DSK files, as created by ADT (http://adt.berlios.de) and ADTPRo (http://adtpro.sourceforge.net) # used by many Apple 2 emulators. # @@ -26,14 +27,21 @@ @file_bytes=file_bytes @files={} end #read in an existing DSK file (must exist) - def DSK.read(filename) - file_bytes=File.new(filename,"rb").read + def DSK.read(filename) + #is the file extension .gz? + if !(filename=~/\.gz$/).nil? then + require 'zlib' + file_bytes=Zlib::GzipReader.new(open(filename,"rb")).read + else + file_bytes=open(filename,"rb").read + end if (file_bytes.length!=DSK_FILE_LENGTH) then abort("#{filename} is not a valid DSK format file") end + dsk=DSK.new(file_bytes) if (dsk.is_dos33?) require 'DOSDisk' dsk=DOSDisk.new(file_bytes) end