This file is indexed.

/usr/lib/ruby/vendor_ruby/rspec/support/directory_maker.rb is in ruby-rspec-support 3.5.0c3e0m0s0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
RSpec::Support.require_rspec_support 'ruby_features'

module RSpec
  module Support
    # @api private
    #
    # Replacement for fileutils#mkdir_p because we don't want to require parts
    # of stdlib in RSpec.
    class DirectoryMaker
      # @api private
      #
      # Implements nested directory construction
      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

      if OS.windows_file_path?
        def self.generate_stack(path)
          if path.start_with?(File::SEPARATOR)
            File::SEPARATOR
          elsif path[1] == ':'
            ''
          else
            '.'
          end
        end
        def self.generate_path(stack, part)
          if stack == ''
            part
          elsif stack == File::SEPARATOR
            File.join('', part)
          else
            File.join(stack, part)
          end
        end
      else
        def self.generate_stack(path)
          path.start_with?(File::SEPARATOR) ? File::SEPARATOR : "."
        end
        def self.generate_path(stack, part)
          File.join(stack, part)
        end
      end

      def self.directory_exists?(dirname)
        File.exist?(dirname) && File.directory?(dirname)
      end
      private_class_method :directory_exists?
      private_class_method :generate_stack
      private_class_method :generate_path
    end
  end
end