X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=bfile%2Fmfile.c;h=7a437c0b56e8f3fcebcbd61fbc097c8fe3d96949;hb=30bb91a2915de98455a8f7a5af5c087239f22203;hp=69a062a8ff16d2f5bc59d9e21f4f9eb12696c78d;hpb=deff57cfa9d9b39c4a4f1c9b82a64c6e61d821a4;p=idzebra-moved-to-github.git diff --git a/bfile/mfile.c b/bfile/mfile.c index 69a062a..7a437c0 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -1,4 +1,4 @@ -/* $Id: mfile.c,v 1.59 2005-03-30 09:25:23 adam Exp $ +/* $Id: mfile.c,v 1.64 2006-05-05 09:14:02 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -32,7 +32,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #ifdef WIN32 #include -#else +#endif +#if HAVE_UNISTD_H #include #endif #include @@ -44,6 +45,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include +#include #include "mfile.h" static int scan_areadef(MFile_area ma, const char *ad, const char *base) @@ -160,7 +162,7 @@ static zint file_position(MFile mf, zint pos, int offset) if (!mf->wr && errno == ENOENT && off == 0) return -2; yaz_log (YLOG_WARN|YLOG_ERRNO, "Failed to open %s", mf->files[c].path); - return -1; + return -1; } } ps = pos - off; @@ -435,7 +437,7 @@ int mf_close(MFile mf) { int i; - yaz_log (YLOG_DEBUG, "mf_close(%s)", mf->name); + yaz_log (YLOG_DEBUG, "mf_close(%s) unlink=%d", mf->name, mf->unlink_flag); assert(mf->open); for (i = 0; i < mf->no_files; i++) { @@ -602,7 +604,9 @@ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) int mf_unlink(MFile mf) { if (mf->open) + { mf->unlink_flag = 1; + } else { int i; @@ -612,11 +616,20 @@ int mf_unlink(MFile mf) return 0; } -/* - * Unlink the file by name, rather than MFile-handle. File should be closed. - */ -int mf_unlink_name(MFile_area ma, const char *name) +int mf_area_directory_stat(MFile_area ma, int no, const char **directory, + double *used_bytes, double *max_bytes) { - abort(); - return 0; + int i; + mf_dir *d = ma->dirs; + for (i = 0; d && inext) + ; + if (!d) + return 0; + if (directory) + *directory = d->name; + if (max_bytes) + *max_bytes = d->max_bytes; + if (used_bytes) + *used_bytes = d->max_bytes - d->avail_bytes; + return 1; }