class RSpec::Support::DirectoryMaker

@api private

Replacement for fileutils#mkdir_p because we don’t want to require parts of stdlib in RSpec.

Public Class Methods

@api private

Implements nested directory construction

# File rspec-support/lib/rspec/support/directory_maker.rb, line 15
def self.mkdir_p(path)
  stack = generate_stack(path)
  path.split(File::SEPARATOR).each do |part|
    stack = generate_path(stack, part)
    begin
      Dir.mkdir(stack) unless directory_exists?(stack)
    rescue Errno::EEXIST => e
      raise e unless directory_exists?(stack)
    rescue Errno::ENOTDIR => e
      raise Errno::EEXIST, e.message
    end
  end
end