зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
14ae6199bf
Коммит
91f5ee89ef
|
@ -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) {
|
||||
}
|
||||
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)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче