Reimplement Language Modelling weights
[xapian.git] / xapian-core / common / posixy_wrapper.h
blob62b706177c64dfe30f294fc682ce6a6b07efec21
1 /** @file
2 * @brief Provides wrappers with POSIXy semantics.
3 */
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
20 * USA
23 #ifndef XAPIAN_INCLUDED_POSIXY_WRAPPER_H
24 #define XAPIAN_INCLUDED_POSIXY_WRAPPER_H
26 #ifdef __WIN32__
27 /** Version of open() which allows the file to be unlinked while open. */
28 int posixy_open(const char *filename, int flags);
30 inline int
31 posixy_open(const char *filename, int flags, int)
33 // mode is ignored.
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);
39 #else
40 # include <cstdio>
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)
47 #endif
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);
55 #else
56 # define posixy_unlink(F) unlink(F)
57 #endif
59 #endif /* XAPIAN_INCLUDED_POSIXY_WRAPPER_H */