summaryrefslogtreecommitdiff
path: root/win32/win32.c
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
commit91f5ee89ef1bf7e85a39a8630335bc2f2c73cc36 (patch)
treea405402ec234e85aeab15ae66babae7f8c678071 /win32/win32.c
parent14ae6199bf57b8da4043e656c11d322d9311389e (diff)
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/win32.c')
-rw-r--r--win32/win32.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 47e35ca..a14cc39 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)) {