summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-20 08:17:53 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-20 08:17:53 +0000
commitb03649bc2a0764fffb969b71f4bf18dcc12fe869 (patch)
tree5143f75961c0b79afea08c2beb768c40b8847d73 /win32
parent7946d2357af1a142d7490a05f7f33531a3f28e81 (diff)
* ext/dbm/dbm.c (fdbm_closed): new method DBM#closed?
* ext/gdbm/gdbm.c (fgdbm_closed): new method GDBM#closed? * ext/sdbm/init.c (fsdbm_closed): new method SDBM#closed? * test/dbm/test_dbm.rb, test/gdbm/test_gdbm.rb, test/sdbm/test_sdbm.rb (teardown): close all db objects before deleting data files. * win32/win32.{ch} (unlink): hook runtime function to change file attribute before unlinking. merge from 1.8, see [ruby-dev:26360] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c20
-rw-r--r--win32/win32.h3
2 files changed, 23 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
//
diff --git a/win32/win32.h b/win32/win32.h
index f073048074..c6aabc42b5 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -131,6 +131,8 @@ extern "C++" {
#define mkdir(p, m) rb_w32_mkdir(p, m)
#undef rmdir
#define rmdir(p) rb_w32_rmdir(p)
+#undef unlink
+#define unlink(p) rb_w32_unlink(p)
#ifdef __MINGW32__
struct timezone {
@@ -197,6 +199,7 @@ extern int rb_w32_isatty(int);
#endif
extern int rb_w32_mkdir(const char *, int);
extern int rb_w32_rmdir(const char *);
+extern int rb_w32_unlink(const char*);
#ifdef __BORLANDC__
extern int rb_w32_fstat(int, struct stat *);