[前][次][番号順一覧][スレッド一覧]

ruby-changes:45567

From: nobu <ko1@a...>
Date: Thu, 16 Feb 2017 17:42:27 +0900 (JST)
Subject: [ruby-changes:45567] nobu:r57640 (trunk): fileutils.rb: do not make root

nobu	2017-02-16 17:42:22 +0900 (Thu, 16 Feb 2017)

  New Revision: 57640

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57640

  Log:
    fileutils.rb: do not make root
    
    * lib/fileutils.rb (FileUtils#mkdir_p): no need to make root
      directory which should be exist and cannot be made with mkdir
      recent Cygwin can make a directory contains a colon.
      [Bug #13214]

  Modified files:
    trunk/lib/fileutils.rb
    trunk/test/fileutils/test_fileutils.rb
Index: test/fileutils/test_fileutils.rb
===================================================================
--- test/fileutils/test_fileutils.rb	(revision 57639)
+++ test/fileutils/test_fileutils.rb	(revision 57640)
@@ -905,6 +905,24 @@ class TestFileUtils < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L905
     mkdir_p '/'
   end
 
+  if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
+    def test_mkdir_p_root
+      if /cygwin/ =~ RUBY_PLATFORM
+        tmpdir = `cygpath -ma .`.chomp
+      else
+        tmpdir = Dir.pwd
+      end
+      skip "No drive letter" unless /\A[a-z]:/i =~ tmpdir
+      drive = "./#{$&}"
+      assert_file_not_exist drive
+      mkdir_p "#{tmpdir}/none/dir"
+      assert_directory "none/dir"
+      assert_file_not_exist drive
+    ensure
+      Dir.rmdir(drive) if drive and File.directory?(drive)
+    end
+  end
+
   def test_mkdir_p_file_perm
     mkdir_p 'tmp/tmp/tmp', :mode => 07777
     assert_directory 'tmp/tmp/tmp'
Index: lib/fileutils.rb
===================================================================
--- lib/fileutils.rb	(revision 57639)
+++ lib/fileutils.rb	(revision 57640)
@@ -201,6 +201,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L201
         stack.push path
         path = File.dirname(path)
       end
+      stack.pop                 # root directory should exist
       stack.reverse_each do |dir|
         begin
           fu_mkdir dir, mode

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]