31 #include "windowsspec.h" 38 for (i = 0; i < bufsize && buf[i] !=
'\0'; i++) {
48 static const int BUFSIZE = 1024;
50 snprintf(target, BUFSIZE,
"%s%s",
GetLocalDir(), filepath);
51 target[BUFSIZE-1] =
'\0';
53 DWORD attr = GetFileAttributes(target);
54 DWORD error = GetLastError();
56 attr == INVALID_FILE_ATTRIBUTES &&
57 (error == ERROR_FILE_NOT_FOUND || error == ERROR_PATH_NOT_FOUND)
61 snprintf(source, BUFSIZE,
"%s%s",
GetDataDir(), filepath);
62 source[BUFSIZE-1] =
'\0';
63 if (SUCCEEDED(CopyFile(source, target, TRUE))) {
64 GfOut(
"Copy success: %s\n", target);
66 GfError(
"Copy failed: %s\n", target);
69 GfError(
"Target directory creation failed: %s\n", target);
78 const char* file[] = {
79 "drivers/human/car.xml",
80 "drivers/human/human.xml",
81 "drivers/human/preferences.xml",
83 "config/raceengine.xml",
90 for (i = 0; i <
sizeof(file)/
sizeof(file[0]); i++) {
95 static const int BUFSIZE = 1024;
98 const char* racemanpath =
"config/raceman";
100 tFList* racemanCur = racemanList;
104 snprintf(path, BUFSIZE,
"%s/%s", racemanpath, racemanCur->
name);
105 path[BUFSIZE-1] =
'\0';
107 racemanCur = racemanCur->
next;
108 }
while (racemanCur != racemanList);
118 TCHAR szLocalAppDataPath[MAX_PATH];
119 if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, szLocalAppDataPath))) {
121 snprintf(buf, bufsize,
"%s/torcs/", szLocalAppDataPath);
130 static void init_args(
int argc,
char **argv,
const char** raceconfig)
135 if ((strncmp(argv[i],
"-s", 2) == 0) || (strncmp(argv[i],
"/s", 2) == 0)) {
138 }
else if ((strncmp(argv[i],
"-r", 2) == 0) || (strncmp(argv[i],
"/r", 2) == 0)) {
143 *raceconfig = argv[i];
147 if ((strlen(*raceconfig) == 0) || (strstr(*raceconfig,
".xml") == 0)) {
148 printf(
"Please specify a race configuration xml when using -r\n");
156 static const int BUFSIZE = 1024;
158 strncpy(buf, argv[0], BUFSIZE);
159 buf[BUFSIZE-1] =
'\0';
160 char *end = strrchr(buf,
'\\');
163 if (end != NULL && buf[1] ==
':') {
175 if (_fullpath(buf, argv[0], BUFSIZE) != NULL &&
176 (strcmp(argv[0],
"wtorcs") == 0 ||
177 strcmp(argv[0],
"wtorcs.exe") == 0)
180 end = strrchr(buf,
'\\');
192 printf(
"Run wtorcs.exe either from the GUI or from the directory which contains wtorcs.exe\n");
217 const char* raceconfig =
"";
222 if (strlen(raceconfig) == 0) {
tFList * GfDirGetListFiltered(const char *dir, const char *suffix)
Get the list of files with matching suffix of a given directory.
void ReRunRaceOnConsole(const char *raceconfig)
int GfCreateDir(char *path)
Create directory for given path recursively, so all missing parent directories are created as well...
List of (DLL) files for a Directory.
The Gaming Framework API (client part).
struct FList * next
Next entry.
int main(int argc, char *argv[])
void SetSingleTextureMode(void)
void SetLibDir(char *buf)
static void convertDelimiter(char *buf, const int bufsize)
void GfScrInit(int argc, char *argv[])
void GfDirFreeList(tFList *list, tfDirfreeUserData freeUserData, bool freename, bool freedispname)
Free a directory list.
static void copyFileIfNotExists(const char *filepath)
void SetDataDir(char *buf)
static void setUserLocalDir(char *buf, const int bufsize)
void SetLocalDir(char *buf)
int GfCreateDirForFile(const char *filenameandpath)
Create directory for given file path recursively, so all missing parent directories are created as we...
static void prepareLocalDir()
static void init_args(int argc, char **argv, const char **raceconfig)