updated ping code to properly work for windows

This commit is contained in:
Mark Vejvoda
2010-06-04 20:11:31 +00:00
parent ce6068b65a
commit 3acc421404
2 changed files with 9 additions and 10 deletions

View File

@@ -584,7 +584,7 @@ void createDirectoryPaths(string Path)
{ {
//if (':' != *(path-1)) //if (':' != *(path-1))
{ {
#ifdef _mkdir #if defined(_mkdir) || defined(WIN32)
_mkdir(DirName); _mkdir(DirName);
#elif defined(mkdir) #elif defined(mkdir)
mkdir(DirName, S_IRWXO); mkdir(DirName, S_IRWXO);
@@ -594,7 +594,7 @@ void createDirectoryPaths(string Path)
*dirName++ = *path++; *dirName++ = *path++;
*dirName = '\0'; *dirName = '\0';
} }
#ifdef _mkdir #if defined(_mkdir) || defined(WIN32)
_mkdir(DirName); _mkdir(DirName);
#elif defined(mkdir) #elif defined(mkdir)
mkdir(DirName, S_IRWXO); mkdir(DirName, S_IRWXO);

View File

@@ -1761,12 +1761,11 @@ float Socket::getAveragePingMS(std::string host, int pingCount) {
sprintf(szCmd,"ping -c %d %s",pingCount,host.c_str()); sprintf(szCmd,"ping -c %d %s",pingCount,host.c_str());
#endif #endif
if(szCmd[0] != '\0') { if(szCmd[0] != '\0') {
#ifdef _popen
FILE *ping= _popen(szCmd, "r");
#elif defined popen
FILE *ping= popen(szCmd, "r");
#else
FILE *ping= NULL; FILE *ping= NULL;
#if defined(_popen) || defined(WIN32)
ping= _popen(szCmd, "r");
#elif defined(popen)
ping= popen(szCmd, "r");
#endif #endif
if (ping != NULL){ if (ping != NULL){
char buf[4000]=""; char buf[4000]="";
@@ -1775,9 +1774,9 @@ float Socket::getAveragePingMS(std::string host, int pingCount) {
char *data = fgets(&buf[bufferPos], 256, ping); char *data = fgets(&buf[bufferPos], 256, ping);
bufferPos = strlen(buf); bufferPos = strlen(buf);
} }
#ifdef _pclose #if defined(_pclose) || defined(WIN32)
_pclose(ping); _pclose(ping);
#elif defined popen #elif defined(pclose)
pclose(ping); pclose(ping);
#endif #endif