openstudiocore/ruby/openstudio/sketchup_plugin/stdruby/fileutils.rb
#
# Options: mode noop verbose
# 
# Creates a directory and all its parent directories.
# For example,
# 
#   FileUtils.mkdir_p '/usr/local/lib/ruby'
# 
# causes to make following directories, if it does not exist.
#     * /usr
#     * /usr/local
#     * /usr/local/lib
#     * /usr/local/lib/ruby
#
# You can pass several directories at a time in a list.
# 

mode noop verbose
Creates a directory and all its parent directories.
For example.



causes to make following directories, if it does not exist.

You can pass several directories at a time in a list.
mode noop verbose Creates a directory and all its parent directories . For example . causes to make following directories if it does not exist . You can pass several directories at a time in a list .
def mkdir_p(list, options = {})
    fu_check_options options, OPT_TABLE['mkdir_p']
    list = fu_list(list)
    fu_output_message "mkdir -p #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
    return *list if options[:noop]
    list.map {|path| path.sub(%r</\z>, '') }.each do |path|
      begin
        fu_mkdir path, options[:mode]
        next
      rescue SystemCallError
        next if File.directory?(path)
      end
      stack = []
      until path == stack.last   
        stack.push path
        path = File.dirname(path)
      end
      stack.reverse_each do |path|
        begin
          fu_mkdir path, options[:mode]
        rescue SystemCallError => err
          raise unless File.directory?(path)
        end
      end
    end
    return *list
  end
def mkdir_p ( list , options = { } ) fu_check_options options , OPT_TABLE [ 'mkdir_p' ] list = fu_list ( list ) fu_output_message "mkdir -p #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options [ :verbose ] return * list if options [ :noop ] list . map { | path | path . sub ( %r< / \z > , '' ) } . each do | path | begin fu_mkdir path , options [ :mode ] next rescue SystemCallError next if File . directory? ( path ) end stack = [ ] until path == stack . last stack . push path path = File . dirname ( path ) end stack . reverse_each do | path | begin fu_mkdir path , options [ :mode ] rescue SystemCallError => err raise unless File . directory? ( path ) end end end return * list end
Options: mode noop verbose
Creates a directory and all its parent directories.
Options : mode noop verbose Creates a directory and all its parent directories .
# optimize for the most common case
 # dirname("/")=="/", dirname("C:/")=="C:/"

list
options