From 5a7fb9a57cd6d0242015527d5919e2c1c7ede9b3 Mon Sep 17 00:00:00 2001 From: joss17 Date: Tue, 9 Feb 2010 14:11:03 +0000 Subject: [PATCH] solve a bug when the tmpcfg directory already exists under windows git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2255 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/util/rsdir.cc | 59 +++++++++++++++------------------ 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/libretroshare/src/util/rsdir.cc b/libretroshare/src/util/rsdir.cc index 95dbaca3e..0eff04428 100644 --- a/libretroshare/src/util/rsdir.cc +++ b/libretroshare/src/util/rsdir.cc @@ -34,6 +34,8 @@ #include #include #include +#include + #if defined(WIN32) || defined(__CYGWIN__) #include "wtypes.h" @@ -232,51 +234,42 @@ bool RsDirUtil::checkDirectory(std::string dir) bool RsDirUtil::checkCreateDirectory(std::string dir) { - struct stat buf; - int val = stat(dir.c_str(), &buf); - if (val == -1) - { - // directory don't exist. create. +#ifdef RSDIR_DEBUG + std::cerr << "RsDirUtil::checkCreateDirectory() dir: " << dir << std::endl; +#endif + DIR *direc = opendir(dir.c_str()); + if (!direc) + { + // directory don't exist. create. /******************************** WINDOWS/UNIX SPECIFIC PART ******************/ #ifndef WINDOWS_SYS // UNIX - if (-1 == mkdir(dir.c_str(), 0777)) + if (-1 == mkdir(dir.c_str(), 0777)) #else // WIN - if (-1 == mkdir(dir.c_str())) + if (-1 == mkdir(dir.c_str())) #endif /******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - { -#ifdef RSDIR_DEBUG - std::cerr << "check_create_directory() Fatal Error --"; - std::cerr < //#include //#include //#include