# File lib/rake/ext/string.rb, line 138
    def pathmap(spec=nil, &block)
      return self if spec.nil?
      result = "".dup
      spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
        case frag
        when "%f"
          result << File.basename(self)
        when "%n"
          result << File.basename(self).ext
        when "%d"
          result << File.dirname(self)
        when "%x"
          result << File.extname(self)
        when "%X"
          result << self.ext
        when "%p"
          result << self
        when "%s"
          result << (File::ALT_SEPARATOR || File::SEPARATOR)
        when "%-"
          # do nothing
        when "%%"
          result << "%"
        when /%(-?\d+)d/
          result << pathmap_partial($1.to_i)
        when /^%\{([^}]*)\}(\d*[dpfnxX])/
          patterns, operator = $1, $2
          result << pathmap("%" + operator).pathmap_replace(patterns, &block)
        when /^%/
          fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
        else
          result << frag
        end
      end
      result
    end