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

ruby-changes:38271

From: usa <ko1@a...>
Date: Mon, 20 Apr 2015 15:04:49 +0900 (JST)
Subject: [ruby-changes:38271] usa:r50352 (trunk): * win32/win32.c (rb_w32_wreadlink): fixed a bug that a junktion misses

usa	2015-04-20 15:04:28 +0900 (Mon, 20 Apr 2015)

  New Revision: 50352

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

  Log:
    * win32/win32.c (rb_w32_wreadlink): fixed a bug that a junktion misses
      its drive letter.

  Modified files:
    trunk/ChangeLog
    trunk/win32/win32.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50351)
+++ ChangeLog	(revision 50352)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Apr 20 15:02:47 2015  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (rb_w32_wreadlink): fixed a bug that a junktion misses
+	  its drive letter.
+
 Mon Apr 20 12:54:56 2015  SHIBATA Hiroshi  <hsbt@r...>
 
 	* ext/openssl/*: use license instead of licence.
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 50351)
+++ win32/win32.c	(revision 50352)
@@ -4731,9 +4731,18 @@ rb_w32_wreadlink(const WCHAR *path, WCHA https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4731
 	e = EINVAL;
     }
     else {
-	void *name = ((char *)rp.SymbolicLinkReparseBuffer.PathBuffer +
-		      rp.SymbolicLinkReparseBuffer.PrintNameOffset);
-	ret = rp.SymbolicLinkReparseBuffer.PrintNameLength;
+	void *name;
+	if (rp.ReparseTag == IO_REPARSE_TAG_SYMLINK) {
+	    name = ((char *)rp.SymbolicLinkReparseBuffer.PathBuffer +
+		    rp.SymbolicLinkReparseBuffer.PrintNameOffset);
+	    ret = rp.SymbolicLinkReparseBuffer.PrintNameLength;
+	}
+	else { /* IO_REPARSE_TAG_MOUNT_POINT */
+	    /* +4/-4 mean to drop "?\" */
+	    name = ((char *)rp.SymbolicLinkReparseBuffer.PathBuffer +
+		    rp.SymbolicLinkReparseBuffer.SubstituteNameOffset + 4);
+	    ret = rp.SymbolicLinkReparseBuffer.SubstituteNameLength - 4;
+	}
 	((WCHAR *)name)[ret/sizeof(WCHAR)] = L'\0';
 	translate_wchar(name, L'\\', L'/');
 	bufsize *= sizeof(WCHAR);

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

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