]> git.lyx.org Git - lyx.git/blob - src/support/mkdir.C
Make it possible to uses non-ascii labelstring, endlabelstring and
[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 namespace lyx {
33
34
35 int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
36 {
37         // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
38 #if HAVE_MKDIR
39 # if MKDIR_TAKES_ONE_ARG
40         // MinGW32
41         return ::mkdir(pathname.c_str());
42 # else
43         // POSIX
44         return ::mkdir(pathname.c_str(), mode_t(mode));
45 # endif
46 #elif defined(_WIN32)
47         // plain Windows 32
48         return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
49 #elif HAVE__MKDIR
50         return ::_mkdir(pathname.c_str());
51 #else
52 #   error "Don't know how to create a directory on this system."
53 #endif
54 }
55
56
57 } // namespace lyx