Class: ReiserFS::DirectoryEntry
- Inherits:
-
Object
- Object
- ReiserFS::DirectoryEntry
- Defined in:
- lib/fs/ReiserFS/directory_entry.rb
Constant Summary collapse
- ITEM_STAT_V1 =
BinaryStruct.new([ 'v', 'mode', 'v', 'nlinks', 'v', 'uid', 'v', 'gid', 'V', 'size', 'V', 'atime', 'V', 'mtime', 'V', 'ctime', 'V', 'nblocks', 'V', 'first' ])
- SIZEOF_ITEM_STAT_V1 =
ITEM_STAT_V1.size
- ITEM_STAT_V2 =
BinaryStruct.new([ 'v', 'mode', 'a2', 'reserved', 'V', 'nlinks', 'Q', 'size', 'V', 'uid', 'V', 'gid', 'V', 'atime', 'V', 'mtime', 'V', 'ctime', 'V', 'nblocks', 'V', 'first' ])
- SIZEOF_ITEM_STAT_V2 =
ITEM_STAT_V2.size
- PF_O_EXECUTE =
Bits 0 to 8 of file mode.
0x0001
- PF_O_WRITE =
owner execute
0x0002
- PF_O_READ =
owner write
0x0004
- PF_G_EXECUTE =
owner read
0x0008
- PF_G_WRITE =
group execute
0x0010
- PF_G_READ =
group write
0x0020
- PF_U_EXECUTE =
group read
0x0040
- PF_U_WRITE =
user execute
0x0080
- PF_U_READ =
user write
0x0100
- MSK_PERM_OWNER =
For accessor convenience.
(PF_O_EXECUTE | PF_O_WRITE | PF_O_READ)
- MSK_PERM_GROUP =
(PF_G_EXECUTE | PF_G_WRITE | PF_G_READ)
- MSK_PERM_USER =
(PF_U_EXECUTE | PF_U_WRITE | PF_U_READ)
- DF_STICKY =
Bits 9 to 11 of file mode.
0x0200
- DF_SET_GID =
0x0400
- DF_SET_UID =
0x0800
- FM_FIFO =
Bits 12 to 15 of file mode.
0x1000
- FM_CHAR =
fifo device (pipe)
0x2000
- FM_DIRECTORY =
char device
0x4000
- FM_BLOCK_DEV =
directory
0x6000
- FM_FILE =
block device
0x8000
- FM_SYM_LNK =
regular file
0xa000
- FM_SOCKET =
symbolic link
0xc000
- MSK_FILE_MODE =
For accessor convenience.
0xf000
- MSK_IS_DEV =
(FM_FIFO | FM_CHAR | FM_BLOCK_DEV | FM_SOCKET)
Instance Attribute Summary collapse
-
#blockObj ⇒ Object
readonly
Returns the value of attribute blockObj.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #aTime ⇒ Object
- #cTime ⇒ Object
- #gid ⇒ Object
- #groupPermissions ⇒ Object
-
#initialize(blockObj, itemHeader, key) ⇒ DirectoryEntry
constructor
A new instance of DirectoryEntry.
- #isDev? ⇒ Boolean
- #isDir? ⇒ Boolean
- #isFile? ⇒ Boolean
- #isSymLink? ⇒ Boolean
- #length ⇒ Object
- #mTime ⇒ Object
- #ownerPermissions ⇒ Object
- #permissions ⇒ Object
- #uid ⇒ Object
- #userPermissions ⇒ Object
Constructor Details
#initialize(blockObj, itemHeader, key) ⇒ DirectoryEntry
Returns a new instance of DirectoryEntry.
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 70 def initialize(blockObj, itemHeader, key) @itemHeader = itemHeader @blockObj = blockObj @key = key @data = @blockObj.getItem(itemHeader) @version = @blockObj.getItemVersion(itemHeader) statStruct = @version == 0 ? ITEM_STAT_V1 : ITEM_STAT_V2 statSize = @version == 0 ? SIZEOF_ITEM_STAT_V1 : SIZEOF_ITEM_STAT_V2 raise "Stat Structure Length Inconsistency" if statSize != @data.length @stat = statStruct.decode(@data) @mode = @stat['mode'] end |
Instance Attribute Details
#blockObj ⇒ Object (readonly)
Returns the value of attribute blockObj.
68 69 70 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 68 def blockObj @blockObj end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
68 69 70 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 68 def key @key end |
Instance Method Details
#aTime ⇒ Object
124 125 126 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 124 def aTime Time.at(@stat['atime']) end |
#cTime ⇒ Object
128 129 130 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 128 def cTime Time.at(@stat['ctime']) end |
#gid ⇒ Object
120 121 122 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 120 def gid @stat['gid'] end |
#groupPermissions ⇒ Object
108 109 110 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 108 def groupPermissions @mode & MSK_PERM_GROUP end |
#isDev? ⇒ Boolean
92 93 94 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 92 def isDev? @mode & MSK_IS_DEV > 0 end |
#isDir? ⇒ Boolean
84 85 86 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 84 def isDir? @mode & FM_DIRECTORY == FM_DIRECTORY end |
#isFile? ⇒ Boolean
88 89 90 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 88 def isFile? @mode & FM_FILE == FM_FILE end |
#isSymLink? ⇒ Boolean
96 97 98 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 96 def isSymLink? @mode & FM_SYM_LNK == FM_SYM_LNK end |
#length ⇒ Object
136 137 138 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 136 def length @stat['size'] end |
#mTime ⇒ Object
132 133 134 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 132 def mTime Time.at(@stat['mtime']) end |
#ownerPermissions ⇒ Object
104 105 106 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 104 def ownerPermissions @mode & MSK_PERM_OWNER end |
#permissions ⇒ Object
100 101 102 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 100 def @mode & (MSK_PERM_OWNER | MSK_PERM_GROUP | MSK_PERM_USER) end |
#uid ⇒ Object
116 117 118 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 116 def uid @stat['uid'] end |
#userPermissions ⇒ Object
112 113 114 |
# File 'lib/fs/ReiserFS/directory_entry.rb', line 112 def userPermissions @mode & MSK_PERM_USER end |