2003-06-18 09:56:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file mkdir.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
2003-07-28 22:37:28 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-06-18 09:56:10 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-06-18 09:56:10 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2000-01-20 01:41:55 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2004-11-07 13:22:51 +00:00
|
|
|
|
#include "support/lyxlib.h"
|
2006-11-26 21:30:39 +00:00
|
|
|
|
#include "support/filename.h"
|
2004-11-07 13:22:51 +00:00
|
|
|
|
|
2005-04-26 10:30:24 +00:00
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
|
# include <sys/stat.h>
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
|
# include <sys/types.h>
|
|
|
|
|
#endif
|
2000-01-20 01:41:55 +00:00
|
|
|
|
#include <fcntl.h>
|
2005-01-20 15:38:14 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
# include <unistd.h>
|
|
|
|
|
#endif
|
2006-05-29 14:56:08 +00:00
|
|
|
|
#ifdef HAVE_DIRECT_H
|
|
|
|
|
# include <direct.h>
|
|
|
|
|
#endif
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#ifdef _WIN32
|
2005-04-23 00:29:31 +00:00
|
|
|
|
# include <windows.h>
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#endif
|
2000-01-20 01:41:55 +00:00
|
|
|
|
|
2006-11-03 12:36:51 +00:00
|
|
|
|
namespace lyx {
|
2006-11-26 21:30:39 +00:00
|
|
|
|
namespace support {
|
2006-11-03 12:36:51 +00:00
|
|
|
|
|
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
|
int mkdir(FileName const & pathname, unsigned long int mode)
|
2000-01-20 01:41:55 +00:00
|
|
|
|
{
|
2002-12-01 22:59:25 +00:00
|
|
|
|
// FIXME: why don't we have mode_t in lyx::mkdir prototype ??
|
2004-12-16 01:03:34 +00:00
|
|
|
|
#if HAVE_MKDIR
|
|
|
|
|
# if MKDIR_TAKES_ONE_ARG
|
|
|
|
|
// MinGW32
|
2006-11-26 21:30:39 +00:00
|
|
|
|
return ::mkdir(pathname.toFilesystemEncoding().c_str());
|
2006-11-13 10:27:57 +00:00
|
|
|
|
# ifdef WITH_WARNINGS
|
|
|
|
|
# warning "Permissions of created directories are ignored on this system."
|
|
|
|
|
# endif
|
2004-12-16 01:03:34 +00:00
|
|
|
|
# else
|
|
|
|
|
// POSIX
|
2006-11-26 21:30:39 +00:00
|
|
|
|
return ::mkdir(pathname.toFilesystemEncoding().c_str(), mode_t(mode));
|
2004-12-16 01:03:34 +00:00
|
|
|
|
# endif
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#elif defined(_WIN32)
|
2004-12-16 01:03:34 +00:00
|
|
|
|
// plain Windows 32
|
2006-11-26 21:30:39 +00:00
|
|
|
|
return CreateDirectory(pathname.toFilesystemEncoding().c_str(), 0) != 0 ? 0 : -1;
|
2006-11-13 10:27:57 +00:00
|
|
|
|
# ifdef WITH_WARNINGS
|
|
|
|
|
# warning "Permissions of created directories are ignored on this system."
|
|
|
|
|
# endif
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#elif HAVE__MKDIR
|
2006-11-26 21:30:39 +00:00
|
|
|
|
return ::_mkdir(pathname.toFilesystemEncoding().c_str());
|
2006-11-13 10:27:57 +00:00
|
|
|
|
# ifdef WITH_WARNINGS
|
|
|
|
|
# warning "Permissions of created directories are ignored on this system."
|
|
|
|
|
# endif
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#else
|
|
|
|
|
# error "Don't know how to create a directory on this system."
|
2004-12-16 01:03:34 +00:00
|
|
|
|
#endif
|
2000-01-20 01:41:55 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
|
} // namespace support
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|