]> git.lyx.org Git - lyx.git/blob - src/support/mkdir.C
MacOSX compile fix.
[lyx.git] / src / support / mkdir.C
1 /**
2  * \file mkdir.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "support/lyxlib.h"
14
15 #ifdef HAVE_SYS_STAT_H
16 # include <sys/stat.h>
17 #endif
18 #ifdef HAVE_SYS_TYPES_H
19 # include <sys/types.h>
20 #endif
21 #include <fcntl.h>
22 #ifdef HAVE_UNISTD_H
23 # include <unistd.h>
24 #endif
25 #ifdef HAVE_DIRECT_H
26 # include <direct.h>
27 #endif
28 #ifdef _WIN32
29 # include <windows.h>
30 #endif
31
32 int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
33 {
34         // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
35 #if HAVE_MKDIR
36 # if MKDIR_TAKES_ONE_ARG
37         // MinGW32
38         return ::mkdir(pathname.c_str());
39 # else
40         // POSIX
41         return ::mkdir(pathname.c_str(), mode_t(mode));
42 # endif
43 #elif defined(_WIN32)
44         // plain Windows 32
45         return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
46 #elif HAVE__MKDIR
47         return ::_mkdir(pathname.c_str());
48 #else
49 #   error "Don't know how to create a directory on this system."
50 #endif
51 }