lib/DSK.rb in dsktool-0.1.4 vs lib/DSK.rb in dsktool-0.1.5

- old
+ new

@@ -5,20 +5,25 @@ # # For manipulating DSK files, as created by ADT (http://adt.berlios.de) and ADTPRo (http://adtpro.sourceforge.net) # used by many Apple 2 emulators. # class DSK - + + #does this filename have a suitable extension? + def DSK.is_dsk_file?(filename) + !(filename.upcase=~/\.DSK$|\.DSK\.GZ$|\.PO$|\.PO\.GZ$/).nil? + end DSK_FILE_LENGTH=143360 attr_accessor (:file_bytes) # does this DSK have a standard Apple DOS 3.3 VTOC? def is_dos33? # VTOC is at offset 0x11000 # bytes 1/2/3 are a track number, sector number and DOS version number # see if these are reasonable values (@file_bytes[0x11001]<=34) && (@file_bytes[0x11002]<=15) && (@file_bytes[0x11003]==3) end + #create a new DSK structure (in memory, not on disk) def initialize(file_bytes="\0"*DSK_FILE_LENGTH) if (file_bytes.length!=DSK_FILE_LENGTH) then raise "DSK files must be #{DSK_FILE_LENGTH} bytes long (was #{file_bytes.length} bytes)"