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 <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined(WIN32) || defined(__CYGWIN__)
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
#include "wtypes.h"
|
#include "wtypes.h"
|
||||||
@ -232,51 +234,42 @@ bool RsDirUtil::checkDirectory(std::string dir)
|
|||||||
|
|
||||||
bool RsDirUtil::checkCreateDirectory(std::string dir)
|
bool RsDirUtil::checkCreateDirectory(std::string dir)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
#ifdef RSDIR_DEBUG
|
||||||
int val = stat(dir.c_str(), &buf);
|
std::cerr << "RsDirUtil::checkCreateDirectory() dir: " << dir << std::endl;
|
||||||
if (val == -1)
|
#endif
|
||||||
{
|
DIR *direc = opendir(dir.c_str());
|
||||||
// directory don't exist. create.
|
if (!direc)
|
||||||
|
{
|
||||||
|
// directory don't exist. create.
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
#ifndef WINDOWS_SYS // UNIX
|
#ifndef WINDOWS_SYS // UNIX
|
||||||
if (-1 == mkdir(dir.c_str(), 0777))
|
if (-1 == mkdir(dir.c_str(), 0777))
|
||||||
#else // WIN
|
#else // WIN
|
||||||
if (-1 == mkdir(dir.c_str()))
|
if (-1 == mkdir(dir.c_str()))
|
||||||
#endif
|
#endif
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef RSDIR_DEBUG
|
#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;
|
std::cerr <<std::endl<< "\tcannot create:" <<dir<<std::endl;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RSDIR_DEBUG
|
#ifdef RSDIR_DEBUG
|
||||||
std::cerr << "check_create_directory()";
|
std::cerr << "check_create_directory()";
|
||||||
std::cerr <<std::endl<< "\tcreated:" <<dir<<std::endl;
|
std::cerr <<std::endl<< "\tcreated:" <<dir<<std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (!S_ISDIR(buf.st_mode))
|
|
||||||
{
|
|
||||||
// Some other type - error.
|
|
||||||
#ifdef RSDIR_DEBUG
|
#ifdef RSDIR_DEBUG
|
||||||
std::cerr<<"check_create_directory() Fatal Error --";
|
std::cerr << "check_create_directory()";
|
||||||
std::cerr<<std::endl<<"\t"<<dir<<" is nor Directory"<<std::endl;
|
std::cerr <<std::endl<< "\tDir Exists:" <<dir<<std::endl;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 1;
|
||||||
}
|
|
||||||
#ifdef RSDIR_DEBUG
|
|
||||||
std::cerr << "check_create_directory()";
|
|
||||||
std::cerr <<std::endl<< "\tDir Exists:" <<dir<<std::endl;
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
//#include <sys/types.h>
|
//#include <sys/types.h>
|
||||||
//#include <sys/stat.h>
|
//#include <sys/stat.h>
|
||||||
//#include <fcntl.h>
|
//#include <fcntl.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user