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"
|
|
|
|
|
|
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>
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
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
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
int lyx::support::mkdir(std::string 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
|
|
|
|
|
return ::mkdir(pathname.c_str());
|
|
|
|
|
# else
|
|
|
|
|
// POSIX
|
2000-10-19 10:04:36 +00:00
|
|
|
|
return ::mkdir(pathname.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
|
2005-01-31 15:26:40 +00:00
|
|
|
|
return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
|
|
|
|
|
#elif HAVE__MKDIR
|
2006-04-05 23:39:11 +00:00
|
|
|
|
return ::_mkdir(pathname.c_str());
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|