Class: NADOLDisk
Constant Summary
Constants inherited from DSK
Instance Method Summary collapse
- #dump_catalog ⇒ Object
-
#initialize(file_bytes) ⇒ NADOLDisk
constructor
A new instance of NADOLDisk.
-
#read_catalog ⇒ Object
reads the catalog, and populate the “files” array with files CATALOG will be at track $00, sector $03 to track $00, sector $09 each entry consists of $10 bytes, which are: 00-0B - filename - if file is deleted, first byte will be FF 0C-0D - filesize (low byte first) 0E - track of track sector list sector 0F - sector of track sector list sector.
Methods inherited from DSK
#disassemble_sector, #dump_disk, #dump_sector, #files, #get_sector, #is_dos33?, is_dsk_file?, #is_nadol?, read
Constructor Details
#initialize(file_bytes) ⇒ NADOLDisk
Returns a new instance of NADOLDisk.
26 27 28 29 |
# File 'lib/NADOLDisk.rb', line 26 def initialize(file_bytes) super(file_bytes) self.read_catalog end |
Instance Method Details
#dump_catalog ⇒ Object
20 21 22 23 24 |
# File 'lib/NADOLDisk.rb', line 20 def dump_catalog files.each_value { |file| puts "#{sprintf('% 6d',file.contents.length)} #{file.filename}" } end |
#read_catalog ⇒ Object
reads the catalog, and populate the “files” array with files CATALOG will be at track $00, sector $03 to track $00, sector $09 each entry consists of $10 bytes, which are: 00-0B - filename - if file is deleted, first byte will be FF 0C-0D - filesize (low byte first) 0E - track of track sector list sector 0F - sector of track sector list sector
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/NADOLDisk.rb', line 38 def read_catalog 0x300.step(0x9FF,0x10) do |file_descriptive_entry_start| file_descriptive_entry=@file_bytes[file_descriptive_entry_start..file_descriptive_entry_start+0x0F] break if (file_descriptive_entry[0]==0xFF) # skip deleted files filename="" file_descriptive_entry[0..11].to_s.each_byte{|b| filename+=(b.%128).chr} #strip off high bit filename.sub!(/ *$/,"") #strip off trailing spaces full_sectors=file_descriptive_entry[0x0D] bytes_in_last_sector=file_descriptive_entry[0x0C] file_size=full_sectors*256+bytes_in_last_sector if (file_size>0) then contents="" ts_list_track_no=file_descriptive_entry[0x0E] ts_list_sector_no=file_descriptive_entry[0x0F] ts_list=get_sector(ts_list_track_no,ts_list_sector_no) entry_number=0 while entry_number<full_sectors do data_track_no=ts_list[entry_number*2] data_sector_no=ts_list[entry_number*2+1] contents+=get_sector(data_track_no,data_sector_no) entry_number+=1 end if (bytes_in_last_sector>0) then data_track_no=ts_list[entry_number*2] data_sector_no=ts_list[entry_number*2+1] contents+=get_sector(data_track_no,data_sector_no)[0..bytes_in_last_sector-1] end if (NADOLTokenisedFile.can_be_nadol_tokenised_file?(contents)) then @files[filename]= NADOLTokenisedFile.new(filename,contents) else @files[filename]= NADOLFile.new(filename,contents) end end end end |