Class: ReiserFS::DirectoryEntry

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#blockObjObject (readonly)

Returns the value of attribute blockObj.



68
69
70
# File 'lib/fs/ReiserFS/directory_entry.rb', line 68

def blockObj
  @blockObj
end

#keyObject (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

#aTimeObject



124
125
126
# File 'lib/fs/ReiserFS/directory_entry.rb', line 124

def aTime
  Time.at(@stat['atime'])
end

#cTimeObject



128
129
130
# File 'lib/fs/ReiserFS/directory_entry.rb', line 128

def cTime
  Time.at(@stat['ctime'])
end

#gidObject



120
121
122
# File 'lib/fs/ReiserFS/directory_entry.rb', line 120

def gid
  @stat['gid']
end

#groupPermissionsObject



108
109
110
# File 'lib/fs/ReiserFS/directory_entry.rb', line 108

def groupPermissions
  @mode & MSK_PERM_GROUP
end

#isDev?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/fs/ReiserFS/directory_entry.rb', line 92

def isDev?
  @mode & MSK_IS_DEV > 0
end

#isDir?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/fs/ReiserFS/directory_entry.rb', line 84

def isDir?
  @mode & FM_DIRECTORY == FM_DIRECTORY
end

#isFile?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/fs/ReiserFS/directory_entry.rb', line 88

def isFile?
  @mode & FM_FILE == FM_FILE
end

#isSymLink?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/fs/ReiserFS/directory_entry.rb', line 96

def isSymLink?
  @mode & FM_SYM_LNK == FM_SYM_LNK
end

#lengthObject



136
137
138
# File 'lib/fs/ReiserFS/directory_entry.rb', line 136

def length
  @stat['size']
end

#mTimeObject



132
133
134
# File 'lib/fs/ReiserFS/directory_entry.rb', line 132

def mTime
  Time.at(@stat['mtime'])
end

#ownerPermissionsObject



104
105
106
# File 'lib/fs/ReiserFS/directory_entry.rb', line 104

def ownerPermissions
  @mode & MSK_PERM_OWNER
end

#permissionsObject



100
101
102
# File 'lib/fs/ReiserFS/directory_entry.rb', line 100

def permissions
  @mode & (MSK_PERM_OWNER | MSK_PERM_GROUP | MSK_PERM_USER)
end

#uidObject



116
117
118
# File 'lib/fs/ReiserFS/directory_entry.rb', line 116

def uid
  @stat['uid']
end

#userPermissionsObject



112
113
114
# File 'lib/fs/ReiserFS/directory_entry.rb', line 112

def userPermissions
  @mode & MSK_PERM_USER
end