Flowdock
method

mkdir_p_safe

Importance_0
v2_6_3 - Show latest stable - 0 notes - Class: Package
mkdir_p_safe(mkdir, mkdir_options, destination_dir, file_name) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rubygems/package.rb, line 480
  def mkdir_p_safe(mkdir, mkdir_options, destination_dir, file_name)
    destination_dir = File.realpath(File.expand_path(destination_dir))
    parts = mkdir.split(File::SEPARATOR)
    parts.reduce do |path, basename|
      path = File.realpath(path) unless path == ""
      path = File.expand_path(path + File::SEPARATOR + basename)
      lstat = File.lstat path rescue nil
      if !lstat || !lstat.directory?
        unless normalize_path(path).start_with? normalize_path(destination_dir) and (FileUtils.mkdir path, mkdir_options rescue false)
          raise Gem::Package::PathError.new(file_name, destination_dir)
        end
      end
      path
    end
  end
Register or log in to add new notes.