Skip to content

Commit

Permalink
Merge branch 'RB-2.4' into RB-2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed May 16, 2022
2 parents 19afa55 + 1018b37 commit f1add9f
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions Global/PythonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@

#include <cstdlib>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>

#ifdef _MSC_VER
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma warning (disable : 4996)
#else
#include <dirent.h>
#include <sys/stat.h>
#endif

#include "../Global/FStreamsSupport.h"
Expand All @@ -53,24 +54,15 @@ static bool fileExists(const std::string& path)

static bool dirExists(const std::string& path)
{
#ifdef _MSC_VER
char* pathCpy = strcpy(path.c_str());
strcat(path.c_str(), "\\*");
WIN32_FIND_DATA find_data;
HANDLE h = FindFirstFile(pathCpy, &find_data);
pathCpy[strlen(pathCpy) - 2] = '\0';
if (h == INVALID_HANDLE_VALUE) {
return false;
}
FindClose(h);
#else
DIR* d = opendir(path.c_str());
if (d == NULL) {
// https://stackoverflow.com/q/18100097
struct stat info;

if(stat(path.c_str(), &info ) != 0) {
return false;
} else if(info.st_mode & S_IFDIR) {
return true;
}
closedir(d);
#endif
return true;
return false;
}

void setupPythonEnv(const std::string& binPath)
Expand Down

0 comments on commit f1add9f

Please sign in to comment.