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/FileName.h"
16 #ifdef HAVE_SYS_STAT_H
17 # include <sys/stat.h>
19 #ifdef HAVE_SYS_TYPES_H
20 # include <sys/types.h>
37 int mymkdir(char const * pathname, unsigned long int mode)
39 // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
41 # if MKDIR_TAKES_ONE_ARG
43 return ::mkdir(pathname);
44 // FIXME: "Permissions of created directories are ignored on this system."
47 return ::mkdir(pathname, mode_t(mode));
51 return CreateDirectory(pathname, 0) != 0 ? 0 : -1;
52 // FIXME: "Permissions of created directories are ignored on this system."
54 return ::_mkdir(pathname);
55 // FIXME: "Permissions of created directories are ignored on this system."
57 # error "Don't know how to create a directory on this system."
62 int mkdir(FileName const & pathname, unsigned long int mode)
64 return mymkdir(pathname.toFilesystemEncoding().c_str(), mode);
68 // adapted from zlib-1.2.3/contrib/minizip/miniunz.c
69 int makedir(char * newdir, unsigned long int mode)
73 int len = (int)strlen(newdir);
78 buffer = (char*)malloc(len+1);
79 strcpy(buffer,newdir);
81 if (buffer[len-1] == '/')
83 if (mymkdir(buffer, mode) == 0) {
92 while(*p && *p != '\\' && *p != '/')
96 if (mymkdir(buffer, mode) != 0) {
109 } // namespace support