]> git.lyx.org Git - lyx.git/blob - src/support/mkdir.cpp
Converted '#warning ...' into FIXME-comments
[lyx.git] / src / support / mkdir.cpp
1 /**
2  * \file mkdir.cpp
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 #include "support/FileName.h"
15
16 #ifdef HAVE_SYS_STAT_H
17 # include <sys/stat.h>
18 #endif
19 #ifdef HAVE_SYS_TYPES_H
20 # include <sys/types.h>
21 #endif
22 #include <fcntl.h>
23 #ifdef HAVE_UNISTD_H
24 # include <unistd.h>
25 #endif
26 #ifdef HAVE_DIRECT_H
27 # include <direct.h>
28 #endif
29 #ifdef _WIN32
30 # include <windows.h>
31 #endif
32
33 namespace lyx {
34 namespace support {
35
36
37 int mkdir(FileName const & pathname, unsigned long int mode)
38 {
39         // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
40 #if HAVE_MKDIR
41 # if MKDIR_TAKES_ONE_ARG
42         // MinGW32
43         return ::mkdir(pathname.toFilesystemEncoding().c_str());
44         // FIXME: "Permissions of created directories are ignored on this system."
45 # else
46         // POSIX
47         return ::mkdir(pathname.toFilesystemEncoding().c_str(), mode_t(mode));
48 # endif
49 #elif defined(_WIN32)
50         // plain Windows 32
51         return CreateDirectory(pathname.toFilesystemEncoding().c_str(), 0) != 0 ? 0 : -1;
52         // FIXME: "Permissions of created directories are ignored on this system."
53 #elif HAVE__MKDIR
54         return ::_mkdir(pathname.toFilesystemEncoding().c_str());
55         // FIXME: "Permissions of created directories are ignored on this system."
56 #else
57 #   error "Don't know how to create a directory on this system."
58 #endif
59 }
60
61
62 } // namespace support
63 } // namespace lyx