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