Class: Ext4::DirectoryEntry
- Inherits:
-
Object
- Object
- Ext4::DirectoryEntry
- Defined in:
- lib/fs/ext4/directory_entry.rb
Constant Summary collapse
- FT_UNKNOWN =
0
- FT_FILE =
1
- FT_DIRECTORY =
2
- FT_CHAR =
3
- FT_BLOCK =
4
- FT_FIFO =
5
- FT_SOCKET =
6
- FT_SYM_LNK =
7
Instance Attribute Summary collapse
-
#fileType ⇒ Object
Returns the value of attribute fileType.
-
#inode ⇒ Object
readonly
Returns the value of attribute inode.
-
#len ⇒ Object
readonly
Returns the value of attribute len.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #dump ⇒ Object
- #fileTypeString ⇒ Object
-
#initialize(data, new_entry = true) ⇒ DirectoryEntry
constructor
A new instance of DirectoryEntry.
- #isDir? ⇒ Boolean
- #isSymLink? ⇒ Boolean
Constructor Details
#initialize(data, new_entry = true) ⇒ DirectoryEntry
Returns a new instance of DirectoryEntry.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fs/ext4/directory_entry.rb', line 37 def initialize(data, new_entry = true) raise "Ext4::DirectoryEntry.initialize: Nil directory entry data" if data.nil? @isNew = new_entry siz = @isNew ? SIZEOF_DIR_ENTRY_NEW : SIZEOF_DIR_ENTRY_ORIGINAL @de = @isNew ? DIR_ENTRY_NEW.decode(data[0..siz]) : DIR_ENTRY_ORIGINAL.decode(data[0..siz]) # If there's a name get it. @name = data[siz, @de['name_len']] if @de['name_len'] != 0 @inode = @de['inode_val'] @len = @de['entry_len'] @fileType = @de['file_type'] if @isNew end |
Instance Attribute Details
#fileType ⇒ Object
Returns the value of attribute fileType.
35 36 37 |
# File 'lib/fs/ext4/directory_entry.rb', line 35 def fileType @fileType end |
#inode ⇒ Object (readonly)
Returns the value of attribute inode.
34 35 36 |
# File 'lib/fs/ext4/directory_entry.rb', line 34 def inode @inode end |
#len ⇒ Object (readonly)
Returns the value of attribute len.
34 35 36 |
# File 'lib/fs/ext4/directory_entry.rb', line 34 def len @len end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/fs/ext4/directory_entry.rb', line 34 def name @name end |
Instance Method Details
#dump ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/fs/ext4/directory_entry.rb', line 68 def dump out = "\#<#{self.class}:0x#{'%08x' % object_id}>\n" out += "Inode : #{inode}\n" out += "Len : #{len}\n" out += "Name len: 0x#{'%04x' % @de['name_len']}\n" out += "Type : #{fileTypeString}\n" if @isNew out += "Name : #{name}\n" end |
#fileTypeString ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fs/ext4/directory_entry.rb', line 57 def fileTypeString return "UNKNOWN" if @fileType == FT_UNKNOWN return "FILE" if @fileType == FT_FILE return "DIRECTORY" if @fileType == FT_DIRECTORY return "CHAR" if @fileType == FT_CHAR return "BLOCK" if @fileType == FT_BLOCK return "FIFO" if @fileType == FT_FIFO return "SOCKET" if @fileType == FT_SOCKET return "SYMLINK" if @fileType == FT_SYM_LNK end |
#isDir? ⇒ Boolean
49 50 51 |
# File 'lib/fs/ext4/directory_entry.rb', line 49 def isDir? @fileType == FT_DIRECTORY end |
#isSymLink? ⇒ Boolean
53 54 55 |
# File 'lib/fs/ext4/directory_entry.rb', line 53 def isSymLink? @fileType == FT_SYM_LNK end |