]> git.lyx.org Git - lyx.git/blob - src/support/mkdir.C
hopefully fix tex2lyx linking.
[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 #  ifdef WITH_WARNINGS
43 #   warning "Permissions of created directories are ignored on this system."
44 #  endif
45 # else
46         // POSIX
47         return ::mkdir(pathname.c_str(), mode_t(mode));
48 # endif
49 #elif defined(_WIN32)
50         // plain Windows 32
51         return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
52 # ifdef WITH_WARNINGS
53 #  warning "Permissions of created directories are ignored on this system."
54 # endif
55 #elif HAVE__MKDIR
56         return ::_mkdir(pathname.c_str());
57 # ifdef WITH_WARNINGS
58 #  warning "Permissions of created directories are ignored on this system."
59 # endif
60 #else
61 #   error "Don't know how to create a directory on this system."
62 #endif
63 }
64
65
66 } // namespace lyx