From: "Mauricio Fernández" Date: 2004-10-12T02:45:29+09:00 Subject: Re: Forcing DBM.open to be read-only? On Tue, Oct 12, 2004 at 02:26:10AM +0900, Lloyd Zusman wrote: > I'd like to use the DBM routines in ruby, and I want to force DBM.open > to be performed in read-only mode. However, looking at the source code > (in ext/dbm/dbm.c), it looks like ruby always tries to open the database > in read-write mode before trying it in read-only mode [see the > fdbm_initialize() routine, below]. > > Am I misinterpreting something? > > In any case, how can I do a DBM.open with the guarantee that it will > never even try to open the file in read-write mode? maybe DBM.open(filename, 0666, DBM::READER) ? (that sets the RUBY_DBM_RW_BIT... ) > if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) { > mode = 0666; /* default value */ > } [...] > if (flags & RUBY_DBM_RW_BIT) { > flags &= ~RUBY_DBM_RW_BIT; > dbm = dbm_open(RSTRING(file)->ptr, flags, mode); > } -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com