# File lib/DOSDisk.rb, line 264
  def delete_file(filename)
    this_files_catalog_slot=find_catalog_slot(filename)    
    #if file not in catalog, do nothing
    return if this_files_catalog_slot.nil? 
    file_descriptive_entry=get_sector(this_files_catalog_slot.track_no,this_files_catalog_slot.sector_no)[this_files_catalog_slot.offset..this_files_catalog_slot.offset+0x22]
    
    #mark sector as free in sector usage list
    sector_usage_bitmap_sector=get_sector(0x11,0)  
    sectors_to_mark_available=get_track_sector_list(file_descriptive_entry[0x00],file_descriptive_entry[0x01])
    sectors_to_mark_available<<DSKTrackSector.new(file_descriptive_entry[0x01],file_descriptive_entry[0x00])      
    
    sectors_to_mark_available.each do |ts|
      offset_of_byte_containing_this_sector=0x38+(ts.track_no*4)
      if ts.sector_no<8 then 
        offset_of_byte_containing_this_sector+=1
      end
      byte_containing_this_sector=sector_usage_bitmap_sector[offset_of_byte_containing_this_sector]   
      byte_containing_this_sector=byte_containing_this_sector|(2**(ts.sector_no%8))
      sector_usage_bitmap_sector[offset_of_byte_containing_this_sector]=byte_containing_this_sector
    end
    set_sector(0x11,0,sector_usage_bitmap_sector)
    
    #mark slot as available in catalog
    catalog_sector=get_sector(this_files_catalog_slot.track_no,this_files_catalog_slot.sector_no)
    catalog_sector[this_files_catalog_slot.offset+0x20]=catalog_sector[this_files_catalog_slot.offset] #save the current "first track no" in last byte of filename
    catalog_sector[this_files_catalog_slot.offset]=0xFF
    set_sector(this_files_catalog_slot.track_no,this_files_catalog_slot.sector_no,catalog_sector)
  end