aboutsummaryrefslogtreecommitdiffstats
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-26 14:46:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-26 14:46:29 +0000
commit32a6cbfb86c357742328dbac87b9f044ecca6231 (patch)
treea405402ec234e85aeab15ae66babae7f8c678071 /win32
parent327e20832120f56e7ca9ab03ef6212d657bd0487 (diff)
downloadruby-32a6cbfb86c357742328dbac87b9f044ecca6231.tar.gz
win32.c: unlink symlinkd
* win32/win32.c (wunlink): SYMLINKD has to be removed as a directory but not a file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 47e35cab3f..a14cc393ce 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -7235,12 +7235,21 @@ static int
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) {
+ }
+ else if ((attr & SYMLINKD) == SYMLINKD) {
+ ret = RemoveDirectoryW(path);
+ }
+ else {
+ if (attr & FILE_ATTRIBUTE_READONLY) {
+ SetFileAttributesW(path, attr & ~FILE_ATTRIBUTE_READONLY);
+ }
+ ret = DeleteFileW(path);
}
- if (!DeleteFileW(path)) {
+ if (!ret) {
errno = map_errno(GetLastError());
ret = -1;
if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY)) {