PHP 8.2.31
Preview: file_utils.rb Size: 3.66 KB
/proc/thread-self/root/opt/alt/ruby22/lib64/ruby/2.2.0/rake/file_utils.rb

require 'rbconfig'
require 'fileutils'

#--
# This a FileUtils extension that defines several additional commands to be
# added to the FileUtils utility functions.
module FileUtils
  # Path to the currently running Ruby program
  RUBY = ENV['RUBY'] || File.join(
    RbConfig::CONFIG['bindir'],
    RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']).
    sub(/.*\s.*/m, '"\&"')

  OPT_TABLE['sh']  = %w(noop verbose)
  OPT_TABLE['ruby'] = %w(noop verbose)

  # Run the system command +cmd+.  If multiple arguments are given the command
  # is run directly (without the shell, same semantics as Kernel::exec and
  # Kernel::system).
  #
  # It is recommended you use the multiple argument form over interpolating
  # user input for both usability and security reasons.  With the multiple
  # argument form you can easily process files with spaces or other shell
  # reserved characters in them.  With the multiple argument form your rake
  # tasks are not vulnerable to users providing an argument like
  # <code>; rm # -rf /</code>.
  #
  # If a block is given, upon command completion the block is called with an
  # OK flag (true on a zero exit status) and a Process::Status object.
  # Without a block a RuntimeError is raised when the command exits non-zero.
  #
  # Examples:
  #
  #   sh 'ls -ltr'
  #
  #   sh 'ls', 'file with spaces'
  #
  #   # check exit status after command runs
  #   sh %{grep pattern file} do |ok, res|
  #     if ! ok
  #       puts "pattern not found (status = #{res.exitstatus})"
  #     end
  #   end
  #
  def sh(*cmd, &block)
    options = (Hash === cmd.last) ? cmd.pop : {}
    shell_runner = block_given? ? block : create_shell_runner(cmd)
    set_verbose_option(options)
    options[:noop] ||= Rake::FileUtilsExt.nowrite_flag
    Rake.rake_check_options options, :noop, :verbose
    Rake.rake_output_message cmd.join(" ") if options[:verbose]

    unless options[:noop]
      res = rake_system(*cmd)
      status = $?
      status = Rake::PseudoStatus.new(1) if !res && status.nil?
      shell_runner.call(res, status)
    end
  end

  def create_shell_runner(cmd) # :nodoc:
    show_command = cmd.join(" ")
    show_command = show_command[0, 42] + "..." unless $trace
    lambda do |ok, status|
      ok or
        fail "Command failed with status (#{status.exitstatus}): " +
        "[#{show_command}]"
    end
  end
  private :create_shell_runner

  def set_verbose_option(options) # :nodoc:
    unless options.key? :verbose
      options[:verbose] =
        (Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT) ||
        Rake::FileUtilsExt.verbose_flag
    end
  end
  private :set_verbose_option

  def rake_system(*cmd) # :nodoc:
    Rake::AltSystem.system(*cmd)
  end
  private :rake_system

  # Run a Ruby interpreter with the given arguments.
  #
  # Example:
  #   ruby %{-pe '$_.upcase!' <README}
  #
  def ruby(*args, &block)
    options = (Hash === args.last) ? args.pop : {}
    if args.length > 1
      sh(*([RUBY] + args + [options]), &block)
    else
      sh("#{RUBY} #{args.first}", options, &block)
    end
  end

  LN_SUPPORTED = [true]

  #  Attempt to do a normal file link, but fall back to a copy if the link
  #  fails.
  def safe_ln(*args)
    if ! LN_SUPPORTED[0]
      cp(*args)
    else
      begin
        ln(*args)
      rescue StandardError, NotImplementedError
        LN_SUPPORTED[0] = false
        cp(*args)
      end
    end
  end

  # Split a file path into individual directory names.
  #
  # Example:
  #   split_all("a/b/c") =>  ['a', 'b', 'c']
  #
  def split_all(path)
    head, tail = File.split(path)
    return [tail] if head == '.' || tail == '/'
    return [head, tail] if head == '/'
    return split_all(head) + [tail]
  end
end

Directory Contents

Dirs: 4 × Files: 45

Name Size Perms Modified Actions
contrib DIR
- drwxr-xr-x 2024-03-03 22:53:17
Edit Download
ext DIR
- drwxr-xr-x 2024-03-03 22:53:17
Edit Download
lib DIR
- drwxr-xr-x 2023-07-26 14:31:55
Edit Download
loaders DIR
- drwxr-xr-x 2024-03-03 22:53:17
Edit Download
3.17 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download
23.14 KB lrw-r--r-- 2014-12-06 00:22:51
Edit Download
868 B lrw-r--r-- 2014-08-16 03:56:17
Edit Download
1.93 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download
418 B lrw-r--r-- 2014-09-06 09:31:37
Edit Download
2.83 KB lrw-r--r-- 2014-11-05 05:19:15
Edit Download
235 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
5.64 KB lrw-r--r-- 2014-12-06 00:22:51
Edit Download
340 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
670 B lrw-r--r-- 2011-06-23 22:11:55
Edit Download
12.13 KB lrw-r--r-- 2014-09-06 09:31:37
Edit Download
1.26 KB lrw-r--r-- 2014-11-25 07:03:36
Edit Download
3.66 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download
4.05 KB lrw-r--r-- 2013-10-11 21:35:01
Edit Download
144 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
1.16 KB lrw-r--r-- 2014-08-27 12:21:41
Edit Download
431 B lrw-r--r-- 2011-06-23 22:11:55
Edit Download
265 B lrw-r--r-- 2014-11-25 07:03:58
Edit Download
2.27 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download
315 B lrw-r--r-- 2012-11-15 21:59:37
Edit Download
673 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
5.28 KB lrw-r--r-- 2014-11-25 07:03:36
Edit Download
53 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
351 B lrw-r--r-- 2012-11-15 22:32:34
Edit Download
364 B lrw-r--r-- 2012-11-15 22:01:58
Edit Download
2.28 KB lrw-r--r-- 2013-10-11 21:35:01
Edit Download
375 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
770 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
341 B lrw-r--r-- 2011-06-28 02:45:29
Edit Download
153 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
897 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
353 B lrw-r--r-- 2011-06-23 22:11:55
Edit Download
594 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
882 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
11.02 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download
618 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
2.15 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download
119 B lrw-r--r-- 2011-06-23 22:11:55
Edit Download
8.84 KB lrw-r--r-- 2014-11-25 07:03:36
Edit Download
5.55 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download
1.11 KB lrw-r--r-- 2013-10-11 21:35:01
Edit Download
4.78 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download
543 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
156 B lrw-r--r-- 2014-07-15 03:07:37
Edit Download
1.55 KB lrw-r--r-- 2014-07-15 03:07:37
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).