puppet函数 多层路径转换数组
module Puppet::Parser::Functionsnewfunction(:path_to_array, :type => :rvalue) do |args|
res = args
array = []
array.push(args)
if args.size == 1
while res != '/' do
res = File.dirname(res)
array.push(res) if res != '/'
end
elsif args.size == 2
e_count = args - 1
e_count.times do
res = File.dirname(res)
array.push(res) if res != '/'
end
end
return array
end
end
# vim: set ts=2 sw=2 et :
页:
[1]