aboutsummaryrefslogtreecommitdiffstats
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 3e126e64fc..4c916f15ca 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3638,6 +3638,26 @@ rb_w32_rmdir(const char *path)
return ret;
}
+#undef unlink
+int
+rb_w32_unlink(const char *path)
+{
+ DWORD attr;
+ int ret;
+ RUBY_CRITICAL({
+ attr = GetFileAttributes(path);
+ if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY)) {
+ attr &= ~FILE_ATTRIBUTE_READONLY;
+ SetFileAttributes(path, attr);
+ }
+ ret = unlink(path);
+ if (ret < 0 && attr != (DWORD)-1) {
+ SetFileAttributes(path, attr);
+ }
+ });
+ return ret;
+}
+
//
// Fix bcc32's stdio bug
//