Updates to Win32 code to port latest mega-glest features
This commit is contained in:
parent
965a7ac2ba
commit
a731f9c2a9
|
@ -19,14 +19,15 @@
|
|||
#include "util.h"
|
||||
#include "conversion.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <direct.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
#define S_ISDIR(mode) ((mode) & _S_IFDIR)
|
||||
|
||||
|
||||
using namespace Shared::Util;
|
||||
using namespace std;
|
||||
|
||||
|
@ -161,48 +162,48 @@ void PlatformExceptionHandler::install(string dumpFileName){
|
|||
// =====================================================
|
||||
// class Misc
|
||||
// =====================================================
|
||||
void findDirs(const vector<string> &paths, vector<string> &results, bool errorOnNotFound) {
|
||||
results.clear();
|
||||
int pathCount = paths.size();
|
||||
for(int idx = 0; idx < pathCount; idx++) {
|
||||
string path = paths[idx] + "/*.";
|
||||
vector<string> current_results;
|
||||
findAll(path, current_results, false, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
for(int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||
const string current_folder = current_results[folder_index];
|
||||
const string current_folder_path = paths[idx] + "/" + current_folder;
|
||||
if(isdir(current_folder_path.c_str()) == true) {
|
||||
if(std::find(results.begin(),results.end(),current_folder) == results.end()) {
|
||||
results.push_back(current_folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(results.begin(),results.end());
|
||||
}
|
||||
|
||||
void findAll(const vector<string> &paths, const string &fileFilter, vector<string> &results, bool cutExtension, bool errorOnNotFound) {
|
||||
results.clear();
|
||||
int pathCount = paths.size();
|
||||
for(int idx = 0; idx < pathCount; idx++) {
|
||||
string path = paths[idx] + "/" + fileFilter;
|
||||
vector<string> current_results;
|
||||
findAll(path, current_results, cutExtension, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
for(int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||
string ¤t_file = current_results[folder_index];
|
||||
if(std::find(results.begin(),results.end(),current_file) == results.end()) {
|
||||
results.push_back(current_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(results.begin(),results.end());
|
||||
}
|
||||
void findDirs(const vector<string> &paths, vector<string> &results, bool errorOnNotFound) {
|
||||
results.clear();
|
||||
int pathCount = paths.size();
|
||||
for(int idx = 0; idx < pathCount; idx++) {
|
||||
string path = paths[idx] + "/*.";
|
||||
vector<string> current_results;
|
||||
findAll(path, current_results, false, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||
const string current_folder = current_results[folder_index];
|
||||
const string current_folder_path = paths[idx] + "/" + current_folder;
|
||||
if(isdir(current_folder_path.c_str()) == true) {
|
||||
if(std::find(results.begin(),results.end(),current_folder) == results.end()) {
|
||||
results.push_back(current_folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(results.begin(),results.end());
|
||||
}
|
||||
|
||||
void findAll(const vector<string> &paths, const string &fileFilter, vector<string> &results, bool cutExtension, bool errorOnNotFound) {
|
||||
results.clear();
|
||||
int pathCount = paths.size();
|
||||
for(int idx = 0; idx < pathCount; idx++) {
|
||||
string path = paths[idx] + "/" + fileFilter;
|
||||
vector<string> current_results;
|
||||
findAll(path, current_results, cutExtension, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||
string ¤t_file = current_results[folder_index];
|
||||
if(std::find(results.begin(),results.end(),current_file) == results.end()) {
|
||||
results.push_back(current_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(results.begin(),results.end());
|
||||
}
|
||||
|
||||
//finds all filenames like path and stores them in resultys
|
||||
void findAll(const string &path, vector<string> &results, bool cutExtension, bool errorOnNotFound){
|
||||
|
@ -235,7 +236,7 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
|
|||
}
|
||||
|
||||
if(cutExtension){
|
||||
for (int i=0; i<results.size(); ++i){
|
||||
for (unsigned int i=0; i<results.size(); ++i){
|
||||
results.at(i)=cutLastExt(results.at(i));
|
||||
}
|
||||
}
|
||||
|
@ -245,9 +246,9 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
|
|||
|
||||
bool isdir(const char *path)
|
||||
{
|
||||
struct stat stats;
|
||||
bool ret = stat (path, &stats) == 0 && S_ISDIR (stats.st_mode);
|
||||
return ret;
|
||||
struct stat stats;
|
||||
bool ret = stat (path, &stats) == 0 && S_ISDIR (stats.st_mode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool EndsWith(const string &str, const string& key)
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
#include <stdexcept>
|
||||
|
||||
#include "conversion.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
#include <time.h>
|
||||
#include <strstream>
|
||||
#include <algorithm>
|
||||
#include "util.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
#define socklen_t int
|
||||
|
||||
|
@ -155,7 +156,7 @@ const char* WSAGetLastErrorMessage(const char* pcMessagePrefix,
|
|||
namespace Shared{ namespace Platform{
|
||||
|
||||
bool Socket::enableDebugText = true;
|
||||
bool Socket::enableNetworkDebugInfo = true;
|
||||
bool Socket::enableNetworkDebugInfo = true;
|
||||
|
||||
// =====================================================
|
||||
// class Ip
|
||||
|
@ -747,7 +748,7 @@ void ClientSocket::connect(const Ip &ip, int port)
|
|||
if(err < 0)
|
||||
{
|
||||
fprintf(stderr, "In [%s::%s] Before END sock = %d, err = %d, errno = %d\n",__FILE__,__FUNCTION__,sock,err,WSAGetLastError());
|
||||
//throwException(szBuf);
|
||||
//throwException(szBuf);
|
||||
disconnectSocket();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue