]> git.lyx.org Git - lyx.git/blob - src/support/mkdir.C
4a068b42bb6aec8e9a576b1f1366f9fceef329da
[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 _WIN32
26 # include <windows.h>
27 #endif
28
29 int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
30 {
31         // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
32 #if HAVE_MKDIR
33 # if MKDIR_TAKES_ONE_ARG
34         // MinGW32
35         return ::mkdir(pathname.c_str());
36 # else
37         // POSIX
38         return ::mkdir(pathname.c_str(), mode_t(mode));
39 # endif
40 #elif defined(_WIN32)
41         // plain Windows 32
42         return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
43 #elif HAVE__MKDIR
44         return ::_mkdir(pathname.c_str());
45 #else
46 #   error "Don't know how to create a directory on this system."
47 #endif
48 }