lib/slowfat/file_alloc_table.rb
##
# Retrieve a full chain of cluster numbers, starting at a given cluster
# @param start_cluster [Integer] the cluster number to retrieve a chain starting from
# @return [Array<Integer>] a list of clusters in the chain, starting from the cluster provided
Retrieve a full chain of cluster numbers, starting at a given cluster
Retrieve a full chain of cluster numbers starting at a given cluster
def chain_starting_at(start_cluster)
      current_cluster = start_cluster
      current_chain = []
      while current_cluster < @size/2
        @backing.seek base + current_cluster * 2
        (next_cluster, junk) = @backing.read(2).unpack('v')
        if(current_cluster+1 == size/2) then
          current_chain << current_cluster
          return current_chain == [] ? [start_cluster] : current_chain
        elsif(next_cluster >= 0xFFF8 and next_cluster <= 0xFFFF) then
          current_chain << current_cluster
          return current_chain == [] ? [start_cluster] : current_chain
        elsif(next_cluster == 0x0000) then
          current_cluster = current_cluster + 1
        else
          current_chain << current_cluster
          current_cluster = next_cluster
        end
      end
    end
def chain_starting_at ( start_cluster ) current_cluster = start_cluster current_chain = [ ] while current_cluster < @size / 2 @backing . seek base + current_cluster * 2 ( next_cluster , junk ) = @backing . read ( 2 ) . unpack ( 'v' ) if ( current_cluster + 1 == size / 2 ) then current_chain << current_cluster return current_chain == [ ] ? [ start_cluster ] : current_chain elsif ( next_cluster >= 0xFFF8 and next_cluster <= 0xFFFF ) then current_chain << current_cluster return current_chain == [ ] ? [ start_cluster ] : current_chain elsif ( next_cluster == 0x0000 ) then current_cluster = current_cluster + 1 else current_chain << current_cluster current_cluster = next_cluster end end end
Retrieve a full chain of cluster numbers, starting at a given cluster
Retrieve a full chain of cluster numbers starting at a given cluster
#printf("current: 0x%02X next: FAT END\n", current_cluster) # end of cluster marker #printf("current: 0x%02X next: EOC (0x%02X)\n", current_cluster, current_cluster+1) #printf("current: 0x%02X next: FREE (0x%02X)\n", current_cluster, current_cluster+1) # link to next cluster #printf("current: 0x%02X next: 0x%02X\n", current_cluster, next_cluster)
a list of clusters in the chain, starting from the cluster provided
a list of clusters in the chain starting from the cluster provided
Array<Integer>
start_cluster
the cluster number to retrieve a chain starting from
the cluster number to retrieve a chain starting from