ruby-changes:39611
From: nobu <ko1@a...>
Date: Wed, 26 Aug 2015 23:46:39 +0900 (JST)
Subject: [ruby-changes:39611] nobu:r51692 (trunk): win32.c: unlink symlinkd
nobu 2015-08-26 23:46:29 +0900 (Wed, 26 Aug 2015) New Revision: 51692 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51692 Log: win32.c: unlink symlinkd * win32/win32.c (wunlink): SYMLINKD has to be removed as a directory but not a file. Modified files: trunk/win32/win32.c Index: win32/win32.c =================================================================== --- win32/win32.c (revision 51691) +++ win32/win32.c (revision 51692) @@ -7235,12 +7235,21 @@ static int https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L7235 wunlink(const WCHAR *path) { int ret = 0; + const DWORD SYMLINKD = FILE_ATTRIBUTE_REPARSE_POINT|FILE_ATTRIBUTE_DIRECTORY; RUBY_CRITICAL({ const DWORD attr = GetFileAttributesW(path); - if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY)) { - SetFileAttributesW(path, attr & ~FILE_ATTRIBUTE_READONLY); + if (attr == (DWORD)-1) { } - if (!DeleteFileW(path)) { + else if ((attr & SYMLINKD) == SYMLINKD) { + ret = RemoveDirectoryW(path); + } + else { + if (attr & FILE_ATTRIBUTE_READONLY) { + SetFileAttributesW(path, attr & ~FILE_ATTRIBUTE_READONLY); + } + ret = DeleteFileW(path); + } + if (!ret) { errno = map_errno(GetLastError()); ret = -1; if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY)) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/