From 344d600edaecc470f90bab73ea58b1bcb7bcba2b Mon Sep 17 00:00:00 2001 From: Juan Prieto Date: Fri, 11 Jun 2010 05:06:46 +0000 Subject: [PATCH] crae::system createDirectory --- src/creaSystem.cxx | 38 ++++++++++++++++++++++++++++++++++++-- src/creaSystem.h | 5 +++-- 2 files changed, 39 insertions(+), 4 deletions(-) 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 "<