3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
13 #include "support/lyxlib.h"
14 #include "support/debug.h"
15 #include "support/FileName.h"
17 #ifdef HAVE_SYS_STAT_H
18 # include <sys/stat.h>
20 #ifdef HAVE_SYS_TYPES_H
21 # include <sys/types.h>
38 int mymkdir(char const * pathname, unsigned long int mode)
40 LYXERR0("MKDIR" << pathname);
41 // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
43 # if MKDIR_TAKES_ONE_ARG
45 return ::mkdir(pathname);
46 // FIXME: "Permissions of created directories are ignored on this system."
49 return ::mkdir(pathname, mode_t(mode));
53 return CreateDirectory(pathname, 0) != 0 ? 0 : -1;
54 // FIXME: "Permissions of created directories are ignored on this system."
56 return ::_mkdir(pathname);
57 // FIXME: "Permissions of created directories are ignored on this system."
59 # error "Don't know how to create a directory on this system."
64 int mkdir(FileName const & pathname, unsigned long int mode)
66 return mymkdir(pathname.toFilesystemEncoding().c_str(), mode);
70 // adapted from zlib-1.2.3/contrib/minizip/miniunz.c
71 int makedir(char * newdir, unsigned long int mode)
75 int len = (int)strlen(newdir);
80 buffer = (char*)malloc(len+1);
81 strcpy(buffer,newdir);
83 if (buffer[len-1] == '/')
85 if (mymkdir(buffer, mode) == 0) {
94 while(*p && *p != '\\' && *p != '/')
98 if (mymkdir(buffer, mode) != 0) {
111 } // namespace support