mirror of
https://github.com/glest/glest-source.git
synced 2025-08-22 16:02:50 +02:00
- added the beginning work to support translatable techtrees
This commit is contained in:
@@ -168,6 +168,9 @@ public:
|
||||
// =====================================================
|
||||
void Tokenize(const string& str,vector<string>& tokens,const string& delimiters = " ");
|
||||
bool isdir(const char *path);
|
||||
bool fileExists(const string &path);
|
||||
inline bool folderExists(const string &path) { return isdir(path.c_str()); }
|
||||
|
||||
void findDirs(string path, vector<string> &results, bool errorOnNotFound,bool keepDuplicates);
|
||||
void findDirs(const vector<string> &paths, vector<string> &results, bool errorOnNotFound=false,bool keepDuplicates=false);
|
||||
void findAll(const vector<string> &paths, const string &fileFilter, vector<string> &results, bool cutExtension=false, bool errorOnNotFound=true,bool keepDuplicates=false);
|
||||
|
@@ -79,6 +79,8 @@ public:
|
||||
void setFloat(const string &key, float value);
|
||||
void setString(const string &key, const string &value);
|
||||
|
||||
bool hasString(const string &key) const;
|
||||
|
||||
static bool applyTagsToValue(string &value, std::map<string,string> *mapTagReplacementValues=NULL);
|
||||
static std::map<string,string> getTagReplacementValues(std::map<string,string> *mapExtraTagReplacementValues=NULL);
|
||||
|
||||
|
@@ -203,7 +203,6 @@ float saturate(float value);
|
||||
int round(float f);
|
||||
|
||||
//misc
|
||||
bool fileExists(const string &path);
|
||||
bool checkVersionComptability(string clientVersionString, string serverVersionString);
|
||||
|
||||
template<typename T>
|
||||
|
@@ -421,6 +421,28 @@ bool isdir(const char *path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool fileExists(const string &path) {
|
||||
#ifdef WIN32
|
||||
wstring wstr = utf8_decode(path);
|
||||
FILE* file= _wfopen(wstr.c_str(), L"rb");
|
||||
#else
|
||||
FILE* file= fopen(path.c_str(), "rb");
|
||||
#endif
|
||||
if(file != NULL) {
|
||||
fclose(file);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
//int fileErrno = errno;
|
||||
#ifdef WIN32
|
||||
int fileErrno = errno;
|
||||
DWORD error = GetLastError();
|
||||
string strError = "[#6] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void removeFolder(const string path) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
|
||||
|
||||
|
@@ -416,6 +416,15 @@ const string Properties::getString(const string &key, const char *defaultValueIf
|
||||
}
|
||||
}
|
||||
|
||||
bool Properties::hasString(const string &key) const {
|
||||
PropertyMap::const_iterator it;
|
||||
it= propertyMap.find(key);
|
||||
if(it == propertyMap.end()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Properties::setInt(const string &key, int value){
|
||||
setString(key, intToStr(value));
|
||||
}
|
||||
|
@@ -736,28 +736,6 @@ int round(float f){
|
||||
|
||||
// ==================== misc ====================
|
||||
|
||||
bool fileExists(const string &path) {
|
||||
#ifdef WIN32
|
||||
wstring wstr = utf8_decode(path);
|
||||
FILE* file= _wfopen(wstr.c_str(), L"rb");
|
||||
#else
|
||||
FILE* file= fopen(path.c_str(), "rb");
|
||||
#endif
|
||||
if(file != NULL) {
|
||||
fclose(file);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
//int fileErrno = errno;
|
||||
#ifdef WIN32
|
||||
int fileErrno = errno;
|
||||
DWORD error = GetLastError();
|
||||
string strError = "[#6] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool checkVersionComptability(string clientVersionString, string serverVersionString) {
|
||||
bool compatible = (clientVersionString == serverVersionString);
|
||||
if(compatible == false) {
|
||||
|
Reference in New Issue
Block a user