Sha256: a60a09e18454c364eadb12ec705cd9af0ba478262b270f53b2067aa59fe4e31f

Contents?: true

Size: 1.47 KB

Versions: 7

Compression:

Stored size: 1.47 KB

Contents

class Pa
module ClassMethods::State

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

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

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

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

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


	# get file type
	#
	# file types:
	#   "chardev" "blockdev" "symlink" ..
	#
	# @param [String] path
	# @return [String] 
	def type(path)
		case (t=File.ftype(get(path)))
		when "characterSpecial"
			"chardev"
		when "blockSpecial"
			"blockdev"
		when "link"
			"symlink"
		else
			t
		end
	end # def type


	# is path a mountpoint?
	#
	# @param[String] path
	# @return [Boolean]
	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
end

module State
	def chmod(mode); File.chmod(mode, path) end
	def lchmod(mode); File.lchmod(mode, path) end
	def chown(uid, gid=nil); File.chown(uid, gid, path) end
	def lchown(uid, gid=nil); File.lchown(uid, gid, path) end
	def utime(atime, mtime); File.utime(atime, mtime, path) end
end

end


Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
pa-1.0.2 lib/pa/state.rb
pa-1.0.1 lib/pa/state.rb
pa-1.0.0 lib/pa/state.rb
tagen-1.0.0 lib/tagen/core/pa/state.rb
tagen-0.2.5 lib/tagen/core/pa/state.rb
tagen-0.2.4 lib/tagen/core/pa/state.rb
tagen-0.2.3 lib/tagen/core/pa/state.rb