diff --git a/lib/modules/Yabu.pmod/module.pmod b/lib/modules/Yabu.pmod/module.pmod index 1f9070fd3bf04de411b2e01f5064bcdaa0ee5215..d9a2e2a633c82596e0385557387279b13c6251b9 100644 --- a/lib/modules/Yabu.pmod/module.pmod +++ b/lib/modules/Yabu.pmod/module.pmod @@ -4,7 +4,7 @@ * associated with a unique key. */ -constant cvs_id = "$Id: module.pmod,v 1.12 1999/08/06 23:08:14 hubbe Exp $"; +constant cvs_id = "$Id: module.pmod,v 1.13 1999/08/25 14:24:29 noring Exp $"; #define ERR(msg) throw(({ "(Yabu) "+msg+"\n", backtrace() })) #define IO_ERR(msg) throw(({ sprintf("(Yabu) %s, %s (%d)\n",msg,strerror(errno()),errno()),backtrace() })) @@ -127,6 +127,7 @@ class YabuLog { static private class FileIO { INHERIT_MUTEX static private inherit Stdio.File:file; + static private string filemode; static private void seek(int offset) { @@ -165,12 +166,24 @@ static private class FileIO { UNLOCK(); } - void create(string filename, string mode) + void file_close() { - file::create(); - if(!file::open(filename, mode)) + file::close(); + } + + void file_open(string filename) + { + if(!file::open(filename, filemode)) ERR(strerror(file::errno())); } + + void create(string filename, string _filemode) + { + file::create(); + + filemode = _filemode; + file_open(filename); + } } @@ -454,9 +467,11 @@ class Chunk { LOCK(); if(!write) ERR("Cannot move in read mode"); + file_close(); if(!mv(filename, new_filename)) IO_ERR("Move failed"); filename = new_filename; + file_open(filename); UNLOCK(); }