Class: CPIOEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/excavate/extractors/cpio/cpio.rb

Constant Summary collapse

DIRECTORY_FLAG =
0040000

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fileObject

Returns the value of attribute file.



170
171
172
# File 'lib/excavate/extractors/cpio/cpio.rb', line 170

def file
  @file
end

#nameObject

Returns the value of attribute name.



169
170
171
# File 'lib/excavate/extractors/cpio/cpio.rb', line 169

def name
  @name
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


196
197
198
# File 'lib/excavate/extractors/cpio/cpio.rb', line 196

def directory?
  mode & DIRECTORY_FLAG > 0
end

#read(*args) ⇒ Object

def validate



191
192
193
194
# File 'lib/excavate/extractors/cpio/cpio.rb', line 191

def read(*args)
  return nil if directory?
  file.read(*args)
end

#validateObject



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/excavate/extractors/cpio/cpio.rb', line 174

def validate
  raise "Invalid magic #{magic.inspect}" if magic != 0x070701
  raise "Invalid ino #{ino.inspect}" if ino < 0
  raise "Invalid mode #{mode.inspect}" if mode < 0
  raise "Invalid uid #{uid.inspect}" if uid < 0
  raise "Invalid gid #{gid.inspect}" if gid < 0
  raise "Invalid nlink #{nlink.inspect}" if nlink < 0
  raise "Invalid mtime #{mtime.inspect}" if mtime < 0
  raise "Invalid filesize #{filesize.inspect}" if filesize < 0
  raise "Invalid devmajor #{devmajor.inspect}" if devmajor < 0
  raise "Invalid devminor #{devminor.inspect}" if devminor < 0
  raise "Invalid rdevmajor #{rdevmajor.inspect}" if rdevmajor < 0
  raise "Invalid rdevminor #{rdevminor.inspect}" if rdevminor < 0
  raise "Invalid namesize #{namesize.inspect}" if namesize < 0
  raise "Invalid check #{check.inspect}" if check < 0
end