From: Juan Prieto Date: Fri, 11 Jun 2010 05:06:46 +0000 (+0000) Subject: crae::system createDirectory X-Git-Tag: CREATOOLS.2-0-3~16 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=344d600edaecc470f90bab73ea58b1bcb7bcba2b;p=crea.git crae::system createDirectory --- diff --git a/src/creaSystem.cxx b/src/creaSystem.cxx index 3205178..49ca11f 100644 --- a/src/creaSystem.cxx +++ b/src/creaSystem.cxx @@ -4,10 +4,17 @@ #include #ifdef WIN32 -#include /* GetModuleFileName */ -#include + #include /* GetModuleFileName */ + #include + #endif /* WIN32 */ +#ifdef LINUX + #include + #include + #include +#endif + #ifdef __APPLE__ /* assume this is OSX */ #include #include /* _NSGetExecutablePath : must add -framework @@ -220,5 +227,32 @@ std::string System::GetExecutablePath(){ } return name; } + + void System::createDirectory(const char* directorypath){ + #ifdef WIN32 + //TODO + CreateDirectory(directorypath); + #endif + #ifdef LINUX + //! include sys/types.h + //! include sys/stat.h + //! int mkdir(const char *path, mode_t mode); + //! read/write/search permissions for owner and group, and with read/search permissions for others S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH + int returnval = mkdir(directorypath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + + if(returnval != 0){ + if(errno == EEXIST){ + std::cout<<"directory already exists "<