mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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
This commit is contained in:
parent
3269dcce0e
commit
5a7fb9a57c
@ -34,6 +34,8 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#include "wtypes.h"
|
||||
@ -232,9 +234,11 @@ 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)
|
||||
#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 ******************/
|
||||
@ -247,7 +251,7 @@ bool RsDirUtil::checkCreateDirectory(std::string dir)
|
||||
|
||||
{
|
||||
#ifdef RSDIR_DEBUG
|
||||
std::cerr << "check_create_directory() Fatal Error --";
|
||||
std::cerr << "check_create_directory() Fatal Error et oui--";
|
||||
std::cerr <<std::endl<< "\tcannot create:" <<dir<<std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
@ -258,15 +262,7 @@ bool RsDirUtil::checkCreateDirectory(std::string dir)
|
||||
std::cerr <<std::endl<< "\tcreated:" <<dir<<std::endl;
|
||||
#endif
|
||||
}
|
||||
else if (!S_ISDIR(buf.st_mode))
|
||||
{
|
||||
// Some other type - error.
|
||||
#ifdef RSDIR_DEBUG
|
||||
std::cerr<<"check_create_directory() Fatal Error --";
|
||||
std::cerr<<std::endl<<"\t"<<dir<<" is nor Directory"<<std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RSDIR_DEBUG
|
||||
std::cerr << "check_create_directory()";
|
||||
std::cerr <<std::endl<< "\tDir Exists:" <<dir<<std::endl;
|
||||
@ -274,9 +270,6 @@ bool RsDirUtil::checkCreateDirectory(std::string dir)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <dirent.h>
|
||||
//#include <sys/types.h>
|
||||
//#include <sys/stat.h>
|
||||
//#include <fcntl.h>
|
||||
|
Loading…
Reference in New Issue
Block a user