Class: RFuse::Stat

Inherits:
Object
  • Object
show all
Defined in:
lib/rfuse/stat.rb

Overview

Helper class to return from :getattr method

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, permissions, values = {}) ⇒ Stat

Returns a new instance of Stat.



33
34
35
36
37
38
39
40
41
# File 'lib/rfuse/stat.rb', line 33

def initialize(type, permissions, values = {})
  values[:mode] = ((type & S_IFMT) | (permissions & 0o7777))
  @uid, @gid, @size, @mode, @atime, @mtime, @ctime, @dev, @ino, @nlink, @rdev, @blksize, @blocks = Array.new(
    13, 0
  )
  values.each_pair do |k, v|
    instance_variable_set("@#{k}", v)
  end
end

Instance Attribute Details

#atimeInteger, Time

Returns see stat(2).

Returns:

  • (Integer, Time)

    see stat(2)



31
32
33
# File 'lib/rfuse/stat.rb', line 31

def atime
  @atime
end

#blksizeInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def blksize
  @blksize
end

#blocksInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def blocks
  @blocks
end

#ctimeInteger, Time

Returns see stat(2).

Returns:

  • (Integer, Time)

    see stat(2)



31
32
33
# File 'lib/rfuse/stat.rb', line 31

def ctime
  @ctime
end

#devInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def dev
  @dev
end

#gidInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def gid
  @gid
end

#inoInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def ino
  @ino
end

#modeInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def mode
  @mode
end

#mtimeInteger, Time

Returns see stat(2).

Returns:

  • (Integer, Time)

    see stat(2)



31
32
33
# File 'lib/rfuse/stat.rb', line 31

def mtime
  @mtime
end

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def nlink
  @nlink
end

#rdevInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def rdev
  @rdev
end

#sizeInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def size
  @size
end

#uidInteger

Returns see stat(2).

Returns:

  • (Integer)

    see stat(2)



28
29
30
# File 'lib/rfuse/stat.rb', line 28

def uid
  @uid
end

Class Method Details

.const_missing(const) ⇒ Object

See FFI::Stat constants



6
7
8
9
# File 'lib/rfuse/stat.rb', line 6

def self.const_missing(const)
  return super unless FFI::Stat.const_defined?(const)
  FFI::Stat.const_get(const)
end

.directory(mode = 0, values = {}) ⇒ Stat

Returns representing a directory.

Parameters:

  • mode (Fixnum) (defaults to: 0)

    file permissions

  • values (Hash<Symbol,Fixnum>) (defaults to: {})

    initial values for other attributes

Returns:

  • (Stat)

    representing a directory



15
16
17
# File 'lib/rfuse/stat.rb', line 15

def self.directory(mode = 0, values = {})
  new(S_IFDIR, mode, values)
end

.file(mode = 0, values = {}) ⇒ Stat

Returns representing a regular file.

Parameters:

  • mode (Fixnum) (defaults to: 0)

    file permissions

  • values (Hash<Symbol,Fixnum>) (defaults to: {})

    initial values for other attributes

Returns:

  • (Stat)

    representing a regular file



23
24
25
# File 'lib/rfuse/stat.rb', line 23

def self.file(mode = 0, values = {})
  new(S_IFREG, mode, values)
end