tgf: Introduce GfParmReadFileBoth
This new function attempts to read a parameter file from GfLocalDir() first, and from GfDataDir() if not successful. This function will be useful to extract car and track data from both directories. Having car and track data available from GfLocalDir() is required to allow users downloading new cars and tracks without administrator/root privileges.
This commit is contained in:
parent
ed97add0a0
commit
6ec6efadf8
2 changed files with 17 additions and 0 deletions
|
@ -1233,7 +1233,21 @@ GfParmReadBuf (char *buffer)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
GfParmReadFileBoth(const char *file, int mode)
|
||||
{
|
||||
void *ret = GfParmReadFileLocal(file, mode);
|
||||
|
||||
if (!ret)
|
||||
return GfParmReadFile(file, mode);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *GfParmReadFileBoth(const std::string &file, int mode)
|
||||
{
|
||||
return GfParmReadFileBoth(file.c_str(), mode);
|
||||
}
|
||||
|
||||
void *
|
||||
GfParmReadFileLocal(const std::string &file, int mode, bool neededFile)
|
||||
|
|
|
@ -409,6 +409,9 @@ TGF_API char* GfPathNormalizeFile(char* pszPath, size_t nMaxPathLen);
|
|||
/* parameter file read */
|
||||
TGF_API void *GfParmReadFileLocal(const char *file, int mode, bool neededFile = true);
|
||||
TGF_API void *GfParmReadFileLocal(const std::string &file, int mode, bool neededFile = true);
|
||||
/* attempt GfParmReadFileLocal first, then GfParmReadFile */
|
||||
TGF_API void *GfParmReadFileBoth(const char *file, int mode);
|
||||
TGF_API void *GfParmReadFileBoth(const std::string &file, int mode);
|
||||
/* last optional parameter allows usage without logger be available */
|
||||
TGF_API void *GfParmReadFile(const char *file, int mode, bool neededFile = true, bool trace = true);
|
||||
TGF_API void *GfParmReadFile(const std::string &file, int mode, bool neededFile = true, bool trace = true);
|
||||
|
|
Loading…
Reference in a new issue