]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/findlib/bfile.c
BFILE I/O, new console @ commands, regression, file mode restore fixes
[bacula/bacula] / bacula / src / findlib / bfile.c
1 /*
2  *  Bacula low level File I/O routines.  This routine simulates
3  *    open(), read(), write(), and close(), but using native routines.
4  *    I.e. on Windows, we use Windows APIs.
5  *
6  *    Kern Sibbald, April MMIII
7  *
8  *   Version $Id$
9  *
10  */
11 /*
12    Copyright (C) 2000-2003 Kern Sibbald and John Walker
13
14    This program is free software; you can redistribute it and/or
15    modify it under the terms of the GNU General Public License as
16    published by the Free Software Foundation; either version 2 of
17    the License, or (at your option) any later version.
18
19    This program is distributed in the hope that it will be useful,
20    but WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22    General Public License for more details.
23
24    You should have received a copy of the GNU General Public
25    License along with this program; if not, write to the Free
26    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27    MA 02111-1307, USA.
28
29  */
30
31 #include "bacula.h"
32 #include "find.h"
33
34
35 void binit(BFILE *bfd)
36 {
37    bfd->fid = -1;
38 }
39
40 int bopen(BFILE *bfd, const char *pathname, int flags, mode_t mode)
41 {
42    return bfd->fid = open(pathname, flags, mode);
43 }
44
45 int bclose(BFILE *bfd)
46
47    int stat = close(bfd->fid);
48    bfd->fid = -1;
49    return stat;
50 }
51
52 ssize_t bread(BFILE *bfd, void *buf, size_t count)
53 {
54    return read(bfd->fid, buf, count);
55 }
56
57 ssize_t bwrite(BFILE *bfd, void *buf, size_t count)
58 {
59    return write(bfd->fid, buf, count);
60 }
61
62 int is_bopen(BFILE *bfd)
63 {
64    return bfd->fid >= 0;
65 }
66
67 off_t blseek(BFILE *bfd, off_t offset, int whence)
68 {
69    return lseek(bfd->fid, offset, whence);
70 }