文件操作 - gnu.rb
返回文件管理
返回主菜单
删除本文件
文件: /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/module_tool/tar/gnu.rb
编辑文件内容
# frozen_string_literal: true require 'shellwords' class Puppet::ModuleTool::Tar::Gnu def unpack(sourcefile, destdir, owner) safe_sourcefile = Shellwords.shellescape(File.expand_path(sourcefile)) destdir = File.expand_path(destdir) safe_destdir = Shellwords.shellescape(destdir) Puppet::Util::Execution.execute("gzip -dc #{safe_sourcefile} | tar --extract --no-same-owner --directory #{safe_destdir} --file -") Puppet::Util::Execution.execute(['find', destdir, '-type', 'd', '-exec', 'chmod', '755', '{}', '+']) Puppet::Util::Execution.execute(['find', destdir, '-type', 'f', '-exec', 'chmod', 'u+rw,g+r,a-st', '{}', '+']) Puppet::Util::Execution.execute(['chown', '-R', owner, destdir]) end def pack(sourcedir, destfile) safe_sourcedir = Shellwords.shellescape(sourcedir) safe_destfile = Shellwords.shellescape(File.basename(destfile)) Puppet::Util::Execution.execute("tar cf - #{safe_sourcedir} | gzip -c > #{safe_destfile}") end end
修改文件时间
将文件时间修改为当前时间的前一年
删除文件