Module: Pa::State::ClassMethods

Defined in:
lib/pa/state.rb

Instance Method Summary collapse

Instance Method Details

#chmod(mode, *paths) ⇒ Object

See Also:

  • File.chmod


18
19
20
21
# File 'lib/pa/state.rb', line 18

def chmod(mode, *paths)
  paths.map!{|v|get(v)}
  File.chmod(mode, *paths) 
end

#chown(user, group = nil, *paths) ⇒ Object

See Also:

  • File.chown


30
31
32
33
# File 'lib/pa/state.rb', line 30

def chown(user, group=nil, *paths)
  paths.map!{|v|get(v)}
  File.chown(user, group, *paths) 
end

#lchmod(mode, *paths) ⇒ Object

See Also:

  • File.lchmod


24
25
26
27
# File 'lib/pa/state.rb', line 24

def lchmod(mode, *paths)
  paths.map!{|v|get(v)}
  File.lchmod(mode, *paths) 
end

#lchown(user, group = nil, *paths) ⇒ Object

See Also:

  • File.lchown


36
37
38
39
# File 'lib/pa/state.rb', line 36

def lchown(user, group=nil, *paths)
  paths.map!{|v|get(v)}
  File.lchown(user, group, *paths) 
end

#mountpoint?(path) ⇒ Boolean

is path a mountpoint?

@param path

Returns:

  • (Boolean)


71
72
73
74
75
76
77
78
79
80
# File 'lib/pa/state.rb', line 71

def mountpoint?(path)
  path=get(path)
  begin
    stat1 = File.lstat(path)
    stat2 = File.lstat(File.join(path, '..'))
    stat1.dev == stat2.dev && stat1.ino == stat2.ino || stat1.dev != stat2.dev
  rescue Errno::ENOENT
    false
  end
end

#type(path) ⇒ String

get file type

file types:

"chardev" "blockdev" "symlink" ..

Parameters:

  • path (String)

Returns:

  • (String)


54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/pa/state.rb', line 54

def type(path)
  case (t=File.ftype(get(path)))
  when "characterSpecial"
    "chardev"
  when "blockSpecial"
    "blockdev"
  when "link"
    "symlink"
  else
    t
  end
end

#utime(atime, mtime, *paths) ⇒ Object

See Also:

  • File.utime


42
43
44
45
# File 'lib/pa/state.rb', line 42

def utime(atime, mtime, *paths)
  paths.map!{|v|get(v)}
  File.utime(atime, mtime, *paths) 
end