Class: SlowFat::FatFile

Inherits:
Object
  • Object
show all
Defined in:
lib/slowfat/fat_file.rb

Overview

FatFile represents a single file on a FAT filesystem

Instance Method Summary collapse

Constructor Details

#initialize(filesystem:, dentry:) ⇒ FatFile

Initialize a new Directory object (normally only called from Directory’s functions)

Parameters:

  • filesystem (Filesystem)

    the filesystem containing this file

  • dentry (Dentry)

    the directory entry pointing to this file



9
10
11
12
13
# File 'lib/slowfat/fat_file.rb', line 9

def initialize(filesystem:, dentry:)
  @filesystem = filesystem
  @dentry = dentry
  @data = Data.new(backing: filesystem.backing, base: filesystem.data_base, cluster_size: filesystem.cluster_size)
end

Instance Method Details

#contentsString

Return the entire contents of a file

Returns:

  • (String)

    the contents of this file



18
19
20
# File 'lib/slowfat/fat_file.rb', line 18

def contents
  @data.cluster_chain_contents chain: @filesystem.fats[0].chain_starting_at(@dentry.start_cluster), size: @dentry.size
end