Class: XFS::ShortFormDirectoryEntry
- Inherits:
-
Object
- Object
- XFS::ShortFormDirectoryEntry
- Defined in:
- lib/fs/xfs/short_form_directory_entry.rb
Instance Attribute Summary collapse
-
#file_type ⇒ Object
Returns the value of attribute file_type.
-
#inode ⇒ Object
Returns the value of attribute inode.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_length ⇒ Object
readonly
Returns the value of attribute name_length.
-
#short_inode ⇒ Object
readonly
Returns the value of attribute short_inode.
Instance Method Summary collapse
- #device? ⇒ Boolean
- #directory? ⇒ Boolean
- #dot_entry(dots, inode_number) ⇒ Object
- #dump ⇒ Object
- #file? ⇒ Boolean
-
#initialize(data, short_inode, sb, dots = nil, inode_number = nil) ⇒ ShortFormDirectoryEntry
constructor
A new instance of ShortFormDirectoryEntry.
- #symlink? ⇒ Boolean
Constructor Details
#initialize(data, short_inode, sb, dots = nil, inode_number = nil) ⇒ ShortFormDirectoryEntry
Returns a new instance of ShortFormDirectoryEntry.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 57 def initialize(data, short_inode, sb, dots = nil, inode_number = nil) # # If dots is 1 or 2 we need to construct the # "." and ".." directory entries. # return dot_entry(dots, inode_number) if dots raise "XFS::ShortFormDirectoryEntry.initialize: Nil directory entry data" if data.nil? siz = SIZEOF_SHORT_FORM_DIRECTORY_ENTRY @directory_entry = SHORT_FORM_DIRECTORY_ENTRY.decode(data[0..siz]) @name_length = @directory_entry['name_length'] unless @name_length == 0 @name = data[siz, @name_length] @name_length += 1 if sb.version_has_crc? start = siz + @name_length if short_inode ino_size = SIZEOF_SHORT_FORM_SHORT_INO inode = SHORT_FORM_SHORT_INO.decode(data[start..(start + ino_size)]) else ino_size = SIZEOF_SHORT_FORM_LONG_INO inode = SHORT_FORM_LONG_INO.decode(data[start..(start + ino_size)]) end @length = start + ino_size @inode = inode['inode_num'] end end |
Instance Attribute Details
#file_type ⇒ Object
Returns the value of attribute file_type.
29 30 31 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 29 def file_type @file_type end |
#inode ⇒ Object
Returns the value of attribute inode.
29 30 31 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 29 def inode @inode end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
28 29 30 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 28 def length @length end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 28 def name @name end |
#name_length ⇒ Object (readonly)
Returns the value of attribute name_length.
28 29 30 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 28 def name_length @name_length end |
#short_inode ⇒ Object (readonly)
Returns the value of attribute short_inode.
28 29 30 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 28 def short_inode @short_inode end |
Instance Method Details
#device? ⇒ Boolean
43 44 45 46 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 43 def device? @file_type == Inode::FT_CHAR || @file_type == Inode::FT_BLOCK || @file_type == Inode::FT_FIFO || @file_type == Inode::FT_SOCKET end |
#directory? ⇒ Boolean
35 36 37 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 35 def directory? @file_type == Inode::FT_DIRECTORY end |
#dot_entry(dots, inode_number) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 48 def dot_entry(dots, inode_number) @length = 0 @name_length = dots @name = "." @name = ".." if dots == 2 @inode = inode_number # Inode Numbers will be filled in by the caller end |
#dump ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 83 def dump out = "\#<#{self.class}:0x#{format('%08x', object_id)}>\n" out += "Inode : #{inode}\n" out += "Len : #{length}\n" out += "Name : #{name}\n" out end |
#file? ⇒ Boolean
39 40 41 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 39 def file? @file_type == Inode::FT_FILE end |
#symlink? ⇒ Boolean
31 32 33 |
# File 'lib/fs/xfs/short_form_directory_entry.rb', line 31 def symlink? @file_type == Inode::FT_SYM_LNK end |