xapian-core  1.4.25
posixy_wrapper.h
Go to the documentation of this file.
1 
4 /* Copyright 2007 Lemur Consulting Ltd
5  * Copyright 2007,2012,2014,2018 Olly Betts
6  *
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.
11  *
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.
16  *
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
21  */
22 
23 #ifndef XAPIAN_INCLUDED_POSIXY_WRAPPER_H
24 #define XAPIAN_INCLUDED_POSIXY_WRAPPER_H
25 
26 #ifdef __WIN32__
27 
28 int posixy_open(const char *filename, int flags);
29 
30 inline int
31 posixy_open(const char *filename, int flags, int)
32 {
33  // mode is ignored.
34  return posixy_open(filename, flags);
35 }
36 
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
48 
49 #if defined __CYGWIN__ || defined __WIN32__
50 
54 int posixy_unlink(const char * filename);
55 #else
56 # define posixy_unlink(F) unlink(F)
57 #endif
58 
59 #endif /* XAPIAN_INCLUDED_POSIXY_WRAPPER_H */
#define posixy_rename(F, T)
include <sys/stat.h> with portability enhancements
#define posixy_unlink(F)
#define posixy_open
<unistd.h>, but with compat.
include <fcntl.h>, but working around broken platforms.