-/* $Id: mfile.c,v 1.50 2003-02-28 15:28:36 adam Exp $
+/* $Id: mfile.c,v 1.51 2003-03-25 23:47:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
meta_f->next = ma->mfiles;
meta_f->open = 0;
meta_f->cur_file = -1;
+ meta_f->unlink_flag = 0;
ma->mfiles = meta_f;
strcpy(meta_f->name, metaname);
part_f = &meta_f->files[0];
mnew->files[0].top = -1;
mnew->files[0].number = 0;
mnew->files[0].fd = -1;
+ mnew->unlink_flag = 0;
mnew->min_bytes_creat = MF_MIN_BLOCKS_CREAT * block_size;
for (dp = ma->dirs; dp && dp->max_bytes >= 0 && dp->avail_bytes <
mnew->min_bytes_creat; dp = dp->next);
logf (LOG_DEBUG, "mf_close(%s)", mf->name);
assert(mf->open);
for (i = 0; i < mf->no_files; i++)
+ {
if (mf->files[i].fd >= 0)
{
#ifndef WIN32
close(mf->files[i].fd);
mf->files[i].fd = -1;
}
+ if (mf->unlink_flag)
+ unlink(mf->files[i].path);
+ }
mf->open = 0;
return 0;
}
*/
int mf_unlink(MFile mf)
{
- int i;
-
- for (i = 0; i < mf->no_files; i++)
- unlink (mf->files[i].path);
+ if (mf->open)
+ mf->unlink_flag = 1;
+ else
+ {
+ int i;
+ for (i = 0; i<mf->no_files; i++)
+ unlink(mf->files[i].path);
+ }
return 0;
}
-/* $Id: mfile.h,v 1.20 2003-03-21 08:02:24 adam Exp $
+/* $Id: mfile.h,v 1.21 2003-03-25 23:47:24 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
int no_files;
int cur_file;
int open; /* is this file open? */
+ int unlink_flag;
int blocksize;
mfile_off_t min_bytes_creat; /* minimum bytes required to enter directory */
MFile_area ma;