Module: Pa::State::ClassMethods
- Defined in:
- lib/pa/state.rb
Instance Method Summary collapse
- #chmod(mode, *paths) ⇒ Object
- #chown(user, group = nil, *paths) ⇒ Object
- #lchmod(mode, *paths) ⇒ Object
- #lchown(user, group = nil, *paths) ⇒ Object
-
#mountpoint?(path) ⇒ Boolean
is path a mountpoint?.
-
#type(path) ⇒ String
get file type.
- #utime(atime, mtime, *paths) ⇒ Object
Instance Method Details
#chmod(mode, *paths) ⇒ Object
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
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
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
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
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" ..
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
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 |