Skip to content
Snippets Groups Projects
Commit ac31b99f authored by Fredrik Noring's avatar Fredrik Noring
Browse files

Now closing and reopening during file moves (a NT problem).

Rev: lib/modules/Yabu.pmod/module.pmod:1.13
parent 57f4e15b
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* associated with a unique key. * 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 ERR(msg) throw(({ "(Yabu) "+msg+"\n", backtrace() }))
#define IO_ERR(msg) throw(({ sprintf("(Yabu) %s, %s (%d)\n",msg,strerror(errno()),errno()),backtrace() })) #define IO_ERR(msg) throw(({ sprintf("(Yabu) %s, %s (%d)\n",msg,strerror(errno()),errno()),backtrace() }))
...@@ -127,6 +127,7 @@ class YabuLog { ...@@ -127,6 +127,7 @@ class YabuLog {
static private class FileIO { static private class FileIO {
INHERIT_MUTEX INHERIT_MUTEX
static private inherit Stdio.File:file; static private inherit Stdio.File:file;
static private string filemode;
static private void seek(int offset) static private void seek(int offset)
{ {
...@@ -165,12 +166,24 @@ static private class FileIO { ...@@ -165,12 +166,24 @@ static private class FileIO {
UNLOCK(); UNLOCK();
} }
void create(string filename, string mode) void file_close()
{ {
file::create(); file::close();
if(!file::open(filename, mode)) }
void file_open(string filename)
{
if(!file::open(filename, filemode))
ERR(strerror(file::errno())); ERR(strerror(file::errno()));
} }
void create(string filename, string _filemode)
{
file::create();
filemode = _filemode;
file_open(filename);
}
} }
...@@ -454,9 +467,11 @@ class Chunk { ...@@ -454,9 +467,11 @@ class Chunk {
LOCK(); LOCK();
if(!write) if(!write)
ERR("Cannot move in read mode"); ERR("Cannot move in read mode");
file_close();
if(!mv(filename, new_filename)) if(!mv(filename, new_filename))
IO_ERR("Move failed"); IO_ERR("Move failed");
filename = new_filename; filename = new_filename;
file_open(filename);
UNLOCK(); UNLOCK();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment