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

ruby-changes:23221

From: nobu <ko1@a...>
Date: Mon, 9 Apr 2012 23:11:55 +0900 (JST)
Subject: [ruby-changes:23221] nobu:r35271 (trunk): * win32/win32.c (isUNCRoot, winnt_stat): support long UNC.

nobu	2012-04-09 23:10:32 +0900 (Mon, 09 Apr 2012)

  New Revision: 35271

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35271

  Log:
    * win32/win32.c (isUNCRoot, winnt_stat): support long UNC.
      [ruby-core:30623][Feature #3399]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_file.rb
    trunk/win32/win32.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35270)
+++ ChangeLog	(revision 35271)
@@ -1,3 +1,8 @@
+Mon Apr  9 23:10:26 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/win32.c (isUNCRoot, winnt_stat): support long UNC.
+	  [ruby-core:30623][Feature #3399]
+
 Mon Apr  9 15:16:01 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (string_content, parser_yylex): count brace nesting to
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 35270)
+++ win32/win32.c	(revision 35271)
@@ -4407,8 +4407,11 @@
 isUNCRoot(const WCHAR *path)
 {
     if (path[0] == L'\\' && path[1] == L'\\') {
-	const WCHAR *p;
-	for (p = path + 2; *p; p++) {
+	const WCHAR *p = path + 2;
+	if (p[0] == L'?' && p[1] == L'\\') {
+	    p += 2;
+	}
+	for (; *p; p++) {
 	    if (*p == L'\\')
 		break;
 	}
@@ -4577,11 +4580,13 @@
 {
     HANDLE h;
     WIN32_FIND_DATAW wfd;
+    const WCHAR *p = path;
 
     memset(st, 0, sizeof(*st));
     st->st_nlink = 1;
 
-    if (wcspbrk(path, L"?*")) {
+    if (wcsncmp(p, L"\\\\?\\", 4) == 0) p += 4;
+    if (wcspbrk(p, L"?*")) {
 	errno = ENOENT;
 	return -1;
     }
Index: test/ruby/test_file.rb
===================================================================
--- test/ruby/test_file.rb	(revision 35270)
+++ test/ruby/test_file.rb	(revision 35271)
@@ -204,4 +204,14 @@
       assert_equal(File.chmod(0666, file), 1, bug5671)
     end
   end
+
+  if /(bcc|ms|cyg)win|mingw|emx/ =~ RUBY_PLATFORM
+    def test_long_unc
+      feature3399 = '[ruby-core:30623]'
+      path = File.expand_path(__FILE__)
+      assert_nothing_raised(Errno::ENOENT, feature3399) do
+        File.stat("//?/#{path}")
+      end
+    end
+  end
 end

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

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