projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use CAST_ZINT_TO_INT in some places, so we can easily spot casts
[idzebra-moved-to-github.git]
/
bfile
/
mfile.c
diff --git
a/bfile/mfile.c
b/bfile/mfile.c
index
3f673aa
..
2f6500f
100644
(file)
--- a/
bfile/mfile.c
+++ b/
bfile/mfile.c
@@
-1,6
+1,6
@@
-/* $Id: mfile.c,v 1.57 2004-12-08 12:23:08 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
- Index Data Aps
+/* $Id: mfile.c,v 1.66 2006-06-07 10:14:39 adam Exp $
+ Copyright (C) 1995-2006
+ Index Data ApS
This file is part of the Zebra server.
This file is part of the Zebra server.
@@
-32,7
+32,8
@@
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <fcntl.h>
#ifdef WIN32
#include <io.h>
#include <fcntl.h>
#ifdef WIN32
#include <io.h>
-#else
+#endif
+#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <direntz.h>
#include <unistd.h>
#endif
#include <direntz.h>
@@
-43,7
+44,8
@@
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <errno.h>
#include <zebra-lock.h>
#include <errno.h>
#include <zebra-lock.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
+#include <yaz/yaz-util.h>
#include "mfile.h"
static int scan_areadef(MFile_area ma, const char *ad, const char *base)
#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);
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;
}
}
ps = pos - off;
@@
-435,7
+437,7
@@
int mf_close(MFile mf)
{
int i;
{
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++)
{
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)
int mf_unlink(MFile mf)
{
if (mf->open)
+ {
mf->unlink_flag = 1;
mf->unlink_flag = 1;
+ }
else
{
int i;
else
{
int i;
@@
-612,11
+616,34
@@
int mf_unlink(MFile mf)
return 0;
}
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 && i<no; i++, d = d->next)
+ ;
+ if (!d)
+ return 0;
+ if (directory)
+ *directory = d->name;
+ if (max_bytes)
+ {
+ /* possible loss of data. But it's just statistics and lies */
+ *max_bytes = (double) d->max_bytes;
+ }
+ if (used_bytes)
+ {
+ /* possible loss of data. But it's just statistics and lies */
+ *used_bytes = (double) (d->max_bytes - d->avail_bytes);
+ }
+ return 1;
}
}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+