- updates to commondata handling. From now on commondata tag specified the commondata folder under a techtree making it easier to share data and portable since you just need to copy the techtree and its contents, this means no sharing data between techtrees (which is good since we don't want such dependencies)

This commit is contained in:
Mark Vejvoda
2011-05-06 22:12:16 +00:00
parent 9c992ed353
commit 449e3f25c8
28 changed files with 324 additions and 119 deletions

View File

@@ -1807,16 +1807,18 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
while(fgets(buffer,MAX_LEN_SINGLE_LINE + 2,fp1)) {
buff_ptr = buffer;
while ((find_ptr = strstr(buff_ptr,findText.c_str()))) {
//printf("Replacing text [%s] with [%s] in file [%s]\n",findText.c_str(),replaceText.c_str(),fileName.c_str());
if(findText != "") {
while ((find_ptr = strstr(buff_ptr,findText.c_str()))) {
//printf("Replacing text [%s] with [%s] in file [%s]\n",findText.c_str(),replaceText.c_str(),fileName.c_str());
while(buff_ptr < find_ptr) {
fputc((int)*buff_ptr++,fp2);
while(buff_ptr < find_ptr) {
fputc((int)*buff_ptr++,fp2);
}
fputs(replaceText.c_str(),fp2);
buff_ptr += find_len;
replacedText = true;
}
fputs(replaceText.c_str(),fp2);
buff_ptr += find_len;
replacedText = true;
}
fputs(buff_ptr,fp2);
}
@@ -1835,6 +1837,24 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
return replacedText;
}
void copyFileTo(string fromFileName, string toFileName) {
const int MAX_LEN_SINGLE_LINE = 4096;
char buffer[MAX_LEN_SINGLE_LINE+2];
char *buff_ptr, *find_ptr;
FILE *fp1, *fp2;
fp1 = fopen(fromFileName.c_str(),"r");
fp2 = fopen(toFileName.c_str(),"w");
while(fgets(buffer,MAX_LEN_SINGLE_LINE + 2,fp1)) {
buff_ptr = buffer;
fputs(buff_ptr,fp2);
}
fclose(fp2);
fclose(fp1);
}
// =====================================
// ModeInfo
// =====================================