Class: GlusterFS::Stat

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/glusterfs/stat.rb

Constant Summary collapse

S_IFMT =

bit mask for the file type bit fields

0170000
S_IFSOCK =

socket

0140000
S_IFLNK =

symbolic link

0120000
S_IFREG =

regular file

0100000
S_IFBLK =

block device

0060000
S_IFDIR =

directory

0040000
S_IFCHR =

character device

0020000
S_IFIFO =

FIFO

0010000
S_ISUID =

set UID bit

0004000
S_ISGID =

set-group-ID bit (see below)

0002000
S_ISVTX =

sticky bit (see below)

0001000
S_IRWXU =

mask for file owner permissions

00700
S_IRUSR =

owner has read permission

00400
S_IWUSR =

owner has write permission

00200
S_IXUSR =

owner has execute permission

00100
S_IRWXG =

mask for group permissions

00070
S_IRGRP =

group has read permission

00040
S_IWGRP =

group has write permission

00020
S_IXGRP =

group has execute permission

00010
S_IRWXO =

mask for permissions for others (not in group)

00007
S_IROTH =

others have read permission

00004
S_IWOTH =

others have write permission

00002
S_IXOTH =

others have execute permission

00001

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dir?(lstat) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/glusterfs/stat.rb', line 44

def self.dir?(lstat)
  lstat[:st_mode] & S_IFDIR > 0
end

.file?(lstat) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/glusterfs/stat.rb', line 48

def self.file?(lstat)
  lstat[:st_mode] & S_IFREG > 0
end

.symlink?(lstat) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/glusterfs/stat.rb', line 52

def self.symlink?(lstat)
  lstat[:st_mode] & S_IFLNK > 0
end

Instance Method Details

#to_hashObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/glusterfs/stat.rb', line 56

def to_hash
  {
    :st_dev      => self[:st_dev],
    :st_ino      => self[:st_ino],
    :st_nlink    => self[:st_nlink],
    :st_mode     => self[:st_mode],
    :st_uid      => self[:st_uid],
    :st_gid      => self[:st_gid],
    :st_rdev     => self[:st_rdev],
    :st_size     => self[:st_size],
    :st_blksize  => self[:st_blksize],
    :st_blocks   => self[:st_blocks],
    :st_atime    => self[:st_atime],
    :st_atimesec => self[:st_atimesec],
    :st_mtime    => self[:st_mtime],
    :st_mtimesec => self[:st_mtimesec],
    :st_ctime    => self[:st_ctime],
    :st_ctimesec => self[:st_ctimesec],
  }
end