method
new
v1_9_3_392 -
Show latest stable
-
0 notes -
Class: SDBM
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (38)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
new(p1, p2 = v2)
public
Hide source
static VALUE fsdbm_initialize(int argc, VALUE *argv, VALUE obj) { volatile VALUE file; VALUE vmode; DBM *dbm; struct dbmdata *dbmp; int mode; if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) { mode = 0666; /* default value */ } else if (NIL_P(vmode)) { mode = -1; /* return nil if DB not exist */ } else { mode = NUM2INT(vmode); } FilePathValue(file); dbm = 0; if (mode >= 0) dbm = sdbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT, mode); if (!dbm) dbm = sdbm_open(RSTRING_PTR(file), O_RDWR, 0); if (!dbm) dbm = sdbm_open(RSTRING_PTR(file), O_RDONLY, 0); if (!dbm) { if (mode == -1) return Qnil; rb_sys_fail(RSTRING_PTR(file)); } dbmp = ALLOC(struct dbmdata); DATA_PTR(obj) = dbmp; dbmp->di_dbm = dbm; dbmp->di_size = -1; return obj; }