def self.delete_file(file_system_image,filename)
directory_filename=directory_entry_for_filename(filename)
directory_track_no=18
directory_sector_no=1
while (directory_track_no !=0) do
directory=file_system_image.get_sector(directory_track_no,directory_sector_no)
raise "attempted to read invalid directory sector at T #{directory_track_no} S#{directory_sector_no}" if directory.nil?
8.times do |slot_no|
slot_start=slot_no*0x20
next if directory[slot_start+2]==0
if directory[slot_start+5,16]==directory_filename then
directory[slot_start+2]=0
file_system_image.set_sector(directory_track_no,directory_sector_no,directory)
file_track_no=directory[slot_start+3]
file_sector_no=directory[slot_start+4]
until (file_track_no==0) do
mark_sector_as_free(file_system_image,file_track_no,file_sector_no)
file_sector=file_system_image.get_sector(file_track_no,file_sector_no)
file_track_no=file_sector[0]
file_sector_no=file_sector[1]
end
return
end
end
directory_track_no=directory[00]
directory_sector_no=directory[01]
end
end