void Modlist_Init (void) { WIN32_FIND_DATA fdat, mod_fdat; HANDLE fhnd, mod_fhnd; char dir_string[MAX_OSPATH], mod_string[MAX_OSPATH]; q_snprintf (dir_string, sizeof(dir_string), "%s/*", com_basedir); fhnd = FindFirstFile(dir_string, &fdat); if (fhnd == INVALID_HANDLE_VALUE) return; do { if (!strcmp(fdat.cFileName, ".")) continue; q_snprintf (mod_string, sizeof(mod_string), "%s/%s/progs.dat", com_basedir, fdat.cFileName); mod_fhnd = FindFirstFile(mod_string, &mod_fdat); if (mod_fhnd != INVALID_HANDLE_VALUE) { FindClose(mod_fhnd); Modlist_Add(fdat.cFileName); } else { q_snprintf (mod_string, sizeof(mod_string), "%s/%s/*.pak", com_basedir, fdat.cFileName); mod_fhnd = FindFirstFile(mod_string, &mod_fdat); if (mod_fhnd != INVALID_HANDLE_VALUE) { FindClose(mod_fhnd); Modlist_Add(fdat.cFileName); } } } while (FindNextFile(fhnd, &fdat)); FindClose(fhnd); }
void Modlist_Init (void) { DIR *dir_p, *mod_dir_p; struct dirent *dir_t, *mod_dir_t; char dir_string[MAX_OSPATH], mod_string[MAX_OSPATH]; q_snprintf (dir_string, sizeof(dir_string), "%s/", com_basedir); dir_p = opendir(dir_string); if (dir_p == NULL) return; while ((dir_t = readdir(dir_p)) != NULL) { if (!strcmp(dir_t->d_name, ".") || !strcmp(dir_t->d_name, "..")) continue; q_snprintf(mod_string, sizeof(mod_string), "%s%s/", dir_string, dir_t->d_name); mod_dir_p = opendir(mod_string); if (mod_dir_p == NULL) continue; // find progs.dat and pak file(s) while ((mod_dir_t = readdir(mod_dir_p)) != NULL) { if (!q_strcasecmp(mod_dir_t->d_name, "progs.dat")) { Modlist_Add(dir_t->d_name); break; } if (!q_strcasecmp(COM_FileGetExtension(mod_dir_t->d_name), "pak")) { Modlist_Add(dir_t->d_name); break; } } closedir(mod_dir_p); } closedir(dir_p); }
void Modlist_Init (void) { DIR *dir_p, *mod_dir_p; struct dirent *dir_t, *mod_dir_t; qboolean progs_found, pak_found; char dir_string[MAX_OSPATH], mod_dir_string[MAX_OSPATH]; int i; i = COM_CheckParm ("-basedir"); if (i && i < com_argc-1) q_snprintf (dir_string, sizeof(dir_string), "%s/", com_argv[i+1]); else q_snprintf (dir_string, sizeof(dir_string), "%s/", host_parms->basedir); dir_p = opendir(dir_string); if (dir_p == NULL) return; while ((dir_t = readdir(dir_p)) != NULL) { if ((strcmp(dir_t->d_name, ".") == 0) || (strcmp(dir_t->d_name, "..") == 0)) continue; q_snprintf(mod_dir_string, sizeof(mod_dir_string), "%s%s/", dir_string, dir_t->d_name); mod_dir_p = opendir(mod_dir_string); if (mod_dir_p == NULL) continue; progs_found = false; pak_found = false; // find progs.dat and pak file(s) while ((mod_dir_t = readdir(mod_dir_p)) != NULL) { if ((strcmp(mod_dir_t->d_name, ".") == 0) || (strcmp(mod_dir_t->d_name, "..") == 0)) continue; if (Q_strcasecmp(mod_dir_t->d_name, "progs.dat") == 0) progs_found = true; if (strstr(mod_dir_t->d_name, ".pak") || strstr(mod_dir_t->d_name, ".PAK")) pak_found = true; if (progs_found || pak_found) break; } closedir(mod_dir_p); if (!progs_found && !pak_found) continue; Modlist_Add(dir_t->d_name); } closedir(dir_p); }