more code for searchpath system
git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@146 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable: 4786) // WARNING: identifier XXX was truncated to 255 characters in the debug info
|
#pragma warning(disable: 4786) // WARNING: identifier XXX was truncated to 255 characters in the debug info
|
||||||
#pragma warning(disable: 4503) // WARNING: decorated name length exceeded, name was truncated
|
#pragma warning(disable: 4503) // WARNING: decorated name length exceeded, name was truncated
|
||||||
@@ -423,19 +422,19 @@ bool GetExactFileName(const std::string& abs_searchname, std::string& filename)
|
|||||||
searchpathlist basesearchpaths;
|
searchpathlist basesearchpaths;
|
||||||
void InitBaseSearchPaths() {
|
void InitBaseSearchPaths() {
|
||||||
basesearchpaths.clear();
|
basesearchpaths.clear();
|
||||||
#if defined(MACOSX)
|
#if defined(__APPLE__)
|
||||||
AddToFileList(&basesearchpaths, "${HOME}/Library/Application Support/OpenLieroX");
|
AddToFileList(&basesearchpaths, "${HOME}/Library/Application Support/Commander Genius");
|
||||||
AddToFileList(&basesearchpaths, ".");
|
AddToFileList(&basesearchpaths, ".");
|
||||||
AddToFileList(&basesearchpaths, "${BIN}/../Resources/gamedir");
|
AddToFileList(&basesearchpaths, "${BIN}/../Resources/data");
|
||||||
AddToFileList(&basesearchpaths, SYSTEM_DATA_DIR"/OpenLieroX");
|
AddToFileList(&basesearchpaths, SYSTEM_DATA_DIR"/commandergenius");
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
AddToFileList(&basesearchpaths, "${HOME}/OpenLieroX");
|
AddToFileList(&basesearchpaths, "${HOME}/Commander Genius");
|
||||||
AddToFileList(&basesearchpaths, ".");
|
AddToFileList(&basesearchpaths, ".");
|
||||||
AddToFileList(&basesearchpaths, "${BIN}");
|
AddToFileList(&basesearchpaths, "${BIN}");
|
||||||
#else // all other systems (Linux, *BSD, OS/2, ...)
|
#else // all other systems (Linux, *BSD, OS/2, ...)
|
||||||
AddToFileList(&basesearchpaths, "${HOME}/.OpenLieroX");
|
AddToFileList(&basesearchpaths, "${HOME}/.CommanderGenius");
|
||||||
AddToFileList(&basesearchpaths, ".");
|
AddToFileList(&basesearchpaths, ".");
|
||||||
AddToFileList(&basesearchpaths, SYSTEM_DATA_DIR"/OpenLieroX"); // no use of ${SYSTEM_DATA}, because it is uncommon and could cause confusion to the user
|
AddToFileList(&basesearchpaths, SYSTEM_DATA_DIR"/commandergenius"); // no use of ${SYSTEM_DATA}, because it is uncommon and could cause confusion to the user
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#define CONFIGFILENAME "genius.cfg"
|
std::string CONFIGFILENAME = "genius.cfg";
|
||||||
|
|
||||||
|
|
||||||
CParser::CParser() {
|
CParser::CParser() {
|
||||||
@@ -41,7 +41,7 @@ bool CParser::loadParseFile() // Open, read the list and close the file
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if((fp=fopen(CONFIGFILENAME,"rt")))
|
if((fp=fopen(CONFIGFILENAME.c_str(),"rt")))
|
||||||
{
|
{
|
||||||
while(!feof(fp))
|
while(!feof(fp))
|
||||||
{
|
{
|
||||||
@@ -52,12 +52,9 @@ bool CParser::loadParseFile() // Open, read the list and close the file
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
g_pLogFile->ftextOut(GREEN,"Parser : The file has not been found. When CKP is trying to save the file it will create a new one.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
g_pLogFile->ftextOut(GREEN,"Parser : The file has not been found. When CKP is trying to save the file it will create a new one.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the text which was parsed. This will also copy all stuff of the memory to the file.
|
// Close the text which was parsed. This will also copy all stuff of the memory to the file.
|
||||||
@@ -65,7 +62,7 @@ bool CParser::saveParseFile() // open, write on the file and close
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if((fp=fopen(CONFIGFILENAME,"wt")))
|
if((fp=fopen(CONFIGFILENAME.c_str(),"wt")))
|
||||||
{
|
{
|
||||||
for(std::list<std::string>::iterator i=m_filebuffer.begin() ; i != m_filebuffer.end() ; ++i )
|
for(std::list<std::string>::iterator i=m_filebuffer.begin() ; i != m_filebuffer.end() ; ++i )
|
||||||
fprintf(fp,"%s\n",i->c_str());
|
fprintf(fp,"%s\n",i->c_str());
|
||||||
@@ -73,11 +70,9 @@ bool CParser::saveParseFile() // open, write on the file and close
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
g_pLogFile->ftextOut(RED,"Parser : Error opening the file for write operations. Check your permissions or if the disk is full");
|
||||||
g_pLogFile->ftextOut(RED,"Parser : Error opening the file for write operations. Check your permissions or if the disk is full");
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the value of the to be seeked keyword and returns it as an int.
|
// read the value of the to be seeked keyword and returns it as an int.
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
extern std::string CONFIGFILENAME;
|
||||||
|
|
||||||
class CParser {
|
class CParser {
|
||||||
public:
|
public:
|
||||||
CParser();
|
CParser();
|
||||||
|
|||||||
@@ -10,6 +10,40 @@
|
|||||||
#include "CSettings.h"
|
#include "CSettings.h"
|
||||||
#include "CVideoDriver.h"
|
#include "CVideoDriver.h"
|
||||||
#include "sound/CSound.h"
|
#include "sound/CSound.h"
|
||||||
|
#include "../FindFile.h"
|
||||||
|
#include "../ConfigHandler.h"
|
||||||
|
|
||||||
|
|
||||||
|
void InitSearchPaths() {
|
||||||
|
// have to set to find the config at some of the default places
|
||||||
|
InitBaseSearchPaths();
|
||||||
|
|
||||||
|
std::string value;
|
||||||
|
int i = 1;
|
||||||
|
while(true) {
|
||||||
|
if(!ReadString(CONFIGFILENAME, "FileHandling", "SearchPath" + itoa(i,10), value, ""))
|
||||||
|
break;
|
||||||
|
|
||||||
|
AddToFileList(&tSearchPaths, value);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the basesearchpaths to the searchpathlist as they should be saved in the end
|
||||||
|
for(searchpathlist::const_iterator p1 = basesearchpaths.begin(); p1 != basesearchpaths.end(); i++,p1++) {
|
||||||
|
AddToFileList(&tSearchPaths, *p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// print the searchpaths, this may be very usefull for the user
|
||||||
|
notes << "I have now the following searchpaths (in this order):\n";
|
||||||
|
for(searchpathlist::const_iterator p2 = tSearchPaths.begin(); p2 != tSearchPaths.end(); p2++) {
|
||||||
|
std::string path = *p2;
|
||||||
|
ReplaceFileVariables(path);
|
||||||
|
notes << " " << path << "\n";
|
||||||
|
}
|
||||||
|
notes << " And that's all." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CSettings::CSettings() {
|
CSettings::CSettings() {
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
|
|||||||
Reference in New Issue
Block a user