summaryrefslogtreecommitdiff
path: root/ext/gdbm
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 /ext/gdbm
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 'ext/gdbm')
-rw-r--r--ext/gdbm/gdbm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index d55b04c..a0e2e95 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -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);