bin/dsktool.rb in dsktool-0.1.6 vs bin/dsktool.rb in dsktool-0.2.1
- old
+ new
@@ -17,11 +17,11 @@
# -o | --output FILENAME specify name to save extracted file as
# -r | --raw don't convert basic files to ASCII
# -x | --explode extract all files
# -v | --version show version number
#
-# Currently only works with DOS 3.3 format DSK images
+# Currently only works with DOS 3.3 and NADOL format DSK images
# Will uncompress gzipped files (with extension .gz)
# input files can be URLs
#
# examples:
# dsktool.rb -c DOS3MASTR.dsk.gz
@@ -31,11 +31,11 @@
# dsktool.rb -e HELLO -o HELLO.bas DOS3MASTR.dsk
# dsktool.rb -x DOS3MASTR.dsk.gz
# dsktool.rb -x DOS3MASTR.dsk.gz -o /tmp/DOS3MASTR/
# dsktool.rb -c http://jamtronix.com/dsks/apshai.dsk.gz
-DSKTOOL_VERSION="0.1.6"
+DSKTOOL_VERSION="0.2.1"
#make sure the relevant folder with our libraries is in the require path
lib_path=File.expand_path(File.dirname(__FILE__)+"//..//lib")
$:.unshift(lib_path) unless $:.include?(lib_path)
@@ -52,11 +52,11 @@
opts.on("-h","--help") {RDoc::usage_from_file(__FILE__)}
opts.on("-v","--version") do
puts File.basename($0)+" "+DSKTOOL_VERSION
exit
end
-opts.on("-r","--raw") {extract_mode=:raw}
+opts.on("-r","--") {extract_mode=:raw}
opts.on("-c","--catalog") {catalog=true}
opts.on("-x","--explode") {explode=true}
opts.on("-l","--list FILENAME",String) do |val|
extract_filename=val.upcase
extract_mode=:list
@@ -77,25 +77,25 @@
when (output_filename.nil?) || (explode) then STDOUT
else File.open(output_filename,"wb")
end
if(catalog) then
- if (dsk.is_dos33?) then
+ if (dsk.respond_to?(:dump_catalog)) then
dsk.dump_catalog
else
- puts "#{filename} is not in DOS 3.3 format"
+ puts "#{filename} does not have a recognised file system"
end
end
if(explode) then
output_dir=output_filename.nil??File.basename(filename,".*"):output_filename
if !(File.exists?(output_dir)) then
Dir.mkdir(output_dir)
end
dsk.files.each_value do |f|
- if (raw_mode) then
+ if (extract_mode==:raw) then
output_filename=output_dir+"/"+f.filename+".raw"
File.open(output_filename,"wb") <<f.contents
else
output_filename=output_dir+"/"+f.filename+f.file_extension
File.open(output_filename,"wb") <<f
@@ -111,10 +111,10 @@
else
output_file<< case extract_mode
when :raw then file.contents
when :hex then file.hex_dump
when :list then
- if file.instance_of?(BinaryFile)
+ if file.respond_to?(:disassembly)
file.disassembly
else
puts "'#{extract_filename}' is not a binary file"
exit
end