Module: Pa::ClassMethods::State

Included in:
Pa
Defined in:
lib/tagen/core/pa/state.rb

Instance Method Summary collapse

Instance Method Details

#chmod(mode, *paths) ⇒ Object

See Also:

  • File.chmod


5
# File 'lib/tagen/core/pa/state.rb', line 5

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

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

See Also:

  • File.chown


11
# File 'lib/tagen/core/pa/state.rb', line 11

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


8
# File 'lib/tagen/core/pa/state.rb', line 8

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

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

See Also:

  • File.lchown


14
# File 'lib/tagen/core/pa/state.rb', line 14

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)


45
46
47
48
49
50
51
52
53
54
# File 'lib/tagen/core/pa/state.rb', line 45

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:

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/tagen/core/pa/state.rb', line 27

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


17
# File 'lib/tagen/core/pa/state.rb', line 17

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