Class: SlowFat::Directory::Dentry

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

Overview

Dentry represents one entry inside a Directory.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir_data) ⇒ Dentry

Initialize a new directory entry (normally only called from Directory)



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/slowfat/dir.rb', line 84

def initialize(dir_data)
  case dir_data[0].ord
    when 0x00
      # end of directory entries
      @type = :end_of_dentries
      return
    when 0x2E
      # dot entry
      @dotdir = true
    when 0xE5
      # deleted file
      @deleted = true
  end
  (@filename, @extension, attrib_bits, reserved, mod_date, mod_time, @start_cluster, @size) = dir_data.unpack('A8A3Ca10vvvV')

  @read_only  = attrib_bits & 0x01 > 0
  @hidden     = attrib_bits & 0x02 > 0
  @system     = attrib_bits & 0x04 > 0
  @archive    = attrib_bits & 0x20 > 0
  @device     = attrib_bits & 0x40 > 0

  @type = :file
  @type = :volume_label if attrib_bits & 0x08 > 0
  @type = :directory if attrib_bits & 0x10 > 0
end

Instance Attribute Details

#extensionString (readonly)



73
74
75
# File 'lib/slowfat/dir.rb', line 73

def extension
  @extension
end

#filenameString (readonly)



71
72
73
# File 'lib/slowfat/dir.rb', line 71

def filename
  @filename
end

#sizeInteger (readonly)



77
78
79
# File 'lib/slowfat/dir.rb', line 77

def size
  @size
end

#start_clusterInteger (readonly)



75
76
77
# File 'lib/slowfat/dir.rb', line 75

def start_cluster
  @start_cluster
end

#typeSymbol (readonly)



79
80
81
# File 'lib/slowfat/dir.rb', line 79

def type
  @type
end

Instance Method Details

#archive?Boolean

Returns true if this dentry has the archive attribute set



130
131
132
# File 'lib/slowfat/dir.rb', line 130

def archive?
  @archive
end

#deleted?Boolean

Returns true if this dentry is a file that has been deleted



142
143
144
# File 'lib/slowfat/dir.rb', line 142

def deleted?
  @deleted
end

#device?Boolean

Returns true if this dentry has the device attribute set



136
137
138
# File 'lib/slowfat/dir.rb', line 136

def device?
  @device
end

#dotdir?Boolean

Returns true if this dentry is a dot directory (. or ..)



148
149
150
# File 'lib/slowfat/dir.rb', line 148

def dotdir?
  @dotdir
end

#hidden?Boolean

Returns true if this dentry has the hidden attribute set



118
119
120
# File 'lib/slowfat/dir.rb', line 118

def hidden?
  @hidden
end

#read_only?Boolean

Returns true if this dentry has the read only attribute set



112
113
114
# File 'lib/slowfat/dir.rb', line 112

def read_only?
  @read_only
end

#system?Boolean

Returns true if this dentry has the system attribute set



124
125
126
# File 'lib/slowfat/dir.rb', line 124

def system?
  @system
end