From 21ffac5b1f004e5eae57eeb8d657ec931b8bf6a6 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 20 Jun 2005 07:53:22 +0000 Subject: * 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. fixed: [ruby-dev:26360] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@8648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/win32.c | 20 ++++++++++++++++++++ win32/win32.h | 3 +++ 2 files changed, 23 insertions(+) (limited to 'win32') diff --git a/win32/win32.c b/win32/win32.c index 13c45005d..c5ca26973 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3433,6 +3433,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; +} + #if !defined(__BORLANDC__) && !defined(_WIN32_WCE) int rb_w32_isatty(int fd) diff --git a/win32/win32.h b/win32/win32.h index c73b91bda..6e0b1fe85 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -128,6 +128,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 { @@ -191,6 +193,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 FILE *rb_w32_fopen(const char *, const char *); -- cgit