2 * @brief Provides wrappers with POSIXy semantics.
4 /* Copyright 2007 Lemur Consulting Ltd
5 * Copyright 2007,2012,2014,2018 Olly Betts
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 #ifndef XAPIAN_INCLUDED_POSIXY_WRAPPER_H
24 #define XAPIAN_INCLUDED_POSIXY_WRAPPER_H
27 /** Version of open() which allows the file to be unlinked while open. */
28 int posixy_open(const char *filename
, int flags
);
31 posixy_open(const char *filename
, int flags
, int)
34 return posixy_open(filename
, flags
);
37 /** Version of rename() which overwrites an existing destination file. */
38 int posixy_rename(const char *from
, const char *to
);
41 # include "safeunistd.h"
42 # include <sys/types.h>
43 # include "safesysstat.h"
44 # include "safefcntl.h"
45 # define posixy_open ::open
46 # define posixy_rename(F, T) std::rename(F, T)
49 #if defined __CYGWIN__ || defined __WIN32__
50 /** Version of unlink() with POSIX-like semantics (open files can be unlinked).
52 * NB The file must have been opened with posixy_open() for this to work.
54 int posixy_unlink(const char * filename
);
56 # define posixy_unlink(F) unlink(F)
59 #endif /* XAPIAN_INCLUDED_POSIXY_WRAPPER_H */