]> git.lyx.org Git - lyx.git/blob - src/support/mkdir.C
An improved HAVE_MKDIR patch that compiles also with MinGW.
[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 #include <sys/stat.h>
16 #include <sys/types.h>
17 #include <fcntl.h>
18 #include <unistd.h>
19
20 int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
21 {
22         // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
23 #if HAVE_MKDIR
24 # if MKDIR_TAKES_ONE_ARG
25         // MinGW32
26         return ::mkdir(pathname.c_str());
27 # else
28         // POSIX
29         return ::mkdir(pathname.c_str(), mode_t(mode));
30 # endif
31 #else
32 # if HAVE__MKDIR
33         // plain Windows 32
34         return ::_mkdir(pathname.c_str());
35 # else
36 #  error "Don't know how to create a directory on this system."
37 # endif
38 #endif
39 }