mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
7946d2357a
commit
b03649bc2a
9 changed files with 95 additions and 3 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
Mon Jun 20 17:15:51 2005 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* 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]
|
||||
|
||||
Mon Jun 20 02:15:35 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* gc.c (define_final): document fix: finalizers never get called
|
||||
|
|
|
@ -71,6 +71,21 @@ fdbm_close(obj)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
fdbm_closed(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
struct dbmdata *dbmp;
|
||||
|
||||
Data_Get_Struct(obj, struct dbmdata, dbmp);
|
||||
if (dbmp == 0)
|
||||
return Qtrue;
|
||||
if (dbmp->di_dbm == 0)
|
||||
return Qtrue;
|
||||
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
static VALUE fdbm_alloc _((VALUE));
|
||||
static VALUE
|
||||
fdbm_alloc(klass)
|
||||
|
@ -719,6 +734,7 @@ Init_dbm()
|
|||
|
||||
rb_define_method(rb_cDBM, "initialize", fdbm_initialize, -1);
|
||||
rb_define_method(rb_cDBM, "close", fdbm_close, 0);
|
||||
rb_define_method(rb_cDBM, "closed?", fdbm_closed, 0);
|
||||
rb_define_method(rb_cDBM, "[]", fdbm_aref, 1);
|
||||
rb_define_method(rb_cDBM, "fetch", fdbm_fetch_m, -1);
|
||||
rb_define_method(rb_cDBM, "[]=", fdbm_store, 2);
|
||||
|
|
|
@ -72,6 +72,21 @@ fgdbm_close(obj)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
fgdbm_closed(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
struct dbmdata *dbmp;
|
||||
|
||||
Data_Get_Struct(obj, struct dbmdata, dbmp);
|
||||
if (dbmp == 0)
|
||||
return Qtrue;
|
||||
if (dbmp->di_dbm == 0)
|
||||
return Qtrue;
|
||||
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
static VALUE fgdbm_s_alloc _((VALUE));
|
||||
|
||||
static VALUE
|
||||
|
@ -909,6 +924,7 @@ Init_gdbm()
|
|||
|
||||
rb_define_method(rb_cGDBM, "initialize", fgdbm_initialize, -1);
|
||||
rb_define_method(rb_cGDBM, "close", fgdbm_close, 0);
|
||||
rb_define_method(rb_cGDBM, "closed?", fgdbm_closed, 0);
|
||||
rb_define_method(rb_cGDBM, "[]", fgdbm_aref, 1);
|
||||
rb_define_method(rb_cGDBM, "fetch", fgdbm_fetch_m, -1);
|
||||
rb_define_method(rb_cGDBM, "[]=", fgdbm_store, 2);
|
||||
|
|
|
@ -62,6 +62,21 @@ fsdbm_close(obj)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
fsdbm_closed(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
struct dbmdata *dbmp;
|
||||
|
||||
Data_Get_Struct(obj, struct dbmdata, dbmp);
|
||||
if (dbmp == 0)
|
||||
return Qtrue;
|
||||
if (dbmp->di_dbm == 0)
|
||||
return Qtrue;
|
||||
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
static VALUE fsdbm_alloc _((VALUE));
|
||||
static VALUE
|
||||
fsdbm_alloc(klass)
|
||||
|
@ -700,6 +715,7 @@ Init_sdbm()
|
|||
|
||||
rb_define_method(rb_cDBM, "initialize", fsdbm_initialize, -1);
|
||||
rb_define_method(rb_cDBM, "close", fsdbm_close, 0);
|
||||
rb_define_method(rb_cDBM, "closed?", fsdbm_closed, 0);
|
||||
rb_define_method(rb_cDBM, "[]", fsdbm_aref, 1);
|
||||
rb_define_method(rb_cDBM, "fetch", fsdbm_fetch_m, -1);
|
||||
rb_define_method(rb_cDBM, "[]=", fsdbm_store, 2);
|
||||
|
|
|
@ -42,7 +42,9 @@ if defined? DBM
|
|||
def teardown
|
||||
assert_nil(@dbm.close)
|
||||
assert_nil(@dbm_rdonly.close)
|
||||
GC.start
|
||||
ObjectSpace.each_object(DBM) do |obj|
|
||||
obj.close unless obj.closed?
|
||||
end
|
||||
File.delete *Dir.glob("tmptest_dbm*").to_a
|
||||
p Dir.glob("tmptest_dbm*") if $DEBUG
|
||||
end
|
||||
|
|
|
@ -39,7 +39,9 @@ if defined? GDBM
|
|||
def teardown
|
||||
assert_nil(@gdbm.close)
|
||||
assert_nil(@gdbm_rdonly.close)
|
||||
GC.start
|
||||
ObjectSpace.each_object(GDBM) do |obj|
|
||||
obj.close unless obj.closed?
|
||||
end
|
||||
File.delete *Dir.glob("tmptest_gdbm*").to_a
|
||||
p Dir.glob("tmptest_gdbm*") if $DEBUG
|
||||
end
|
||||
|
|
|
@ -12,7 +12,9 @@ class TestSDBM < Test::Unit::TestCase
|
|||
end
|
||||
def teardown
|
||||
assert_nil(@sdbm.close)
|
||||
GC.start
|
||||
ObjectSpace.each_object(SDBM) do |obj|
|
||||
obj.close unless obj.closed?
|
||||
end
|
||||
File.delete *Dir.glob("tmptest_sdbm*").to_a
|
||||
p Dir.glob("tmptest_sdbm*") if $DEBUG
|
||||
end
|
||||
|
|
|
@ -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
|
||||
//
|
||||
|
|
|
@ -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 *);
|
||||
|
|
Loading…
Reference in a new issue