def getFirstFreeEntry(num_entries = 1, behavior = GF_W98)
      0.step(@data.size - 1, DIR_ENT_SIZE) do |offset|
        next if @data[offset] != DirectoryEntry::AF_NOT_ALLOCATED && @data[offset] != DirectoryEntry::AF_DELETED
        num = countFreeEntries(behavior, @data[offset..-1])
        return offset.divmod(@bs.bytesPerCluster)[1], getClusterStatus(offset).number if num >= num_entries
      end

      # Must allocate another cluster.
      cluster = @bs.allocClusters(@cluster)
      @data += MemoryBuffer.create(@bs.bytesPerCluster)
      @all_clusters << mkClusterStatus(cluster, 0)
      return 0, cluster
    end
def getFirstFreeEntry(num_entries = 1, behavior = GF_W98)
      0.step(@data.size - 1, DIR_ENT_SIZE) do |offset|
        next if @data[offset] != DirectoryEntry::AF_NOT_ALLOCATED && @data[offset] != DirectoryEntry::AF_DELETED
        num = countFreeEntries(behavior, @data[offset..-1])
        return offset.divmod(@bs.bytesPerCluster)[1], getClusterStatus(offset).number if num >= num_entries
      end

      # Must allocate another cluster.
      cluster = @bs.allocClusters(@cluster)
      @data += MemoryBuffer.create(@bs.bytesPerCluster)
      @all_clusters << mkClusterStatus(cluster, 0)
      return 0, cluster
    end
////////////////////////////////////////////////////////////////////////////
 // Utility functions.
 Get free entry or entries in directory data. If not exist, allocate cluster.