char *D_FindWADByName(char *name) { char *path; int i; // Absolute path? if (M_FileExists(name)) return name; BuildIWADDirList(); // Search through all IWAD paths for a file with the given name. for (i = 0; i < num_iwad_dirs; ++i) { // As a special case, if this is in DOOMWADDIR or DOOMWADPATH, // the "directory" may actually refer directly to an IWAD // file. if (D_CheckFilename(iwad_dirs[i], name) && M_FileExists(iwad_dirs[i])) return strdup(iwad_dirs[i]); // Construct a string for the full path path = M_StringJoin(iwad_dirs[i], DIR_SEPARATOR_S, name, NULL); if (M_FileExists(path)) return path; free(path); } // File not found return NULL; }
char *D_FindIWAD(int mask, GameMission_t *mission) { char *result; char *iwadfile; int iwadparm; int i; // Check for the -iwad parameter //! // Specify an IWAD file to use. // // @arg <file> // iwadparm = M_CheckParmWithArgs("-iwad", 1); if (iwadparm) { // Search through IWAD dirs for an IWAD with the given name. iwadfile = myargv[iwadparm + 1]; result = D_FindWADByName(iwadfile); if (result == NULL) { I_Error("IWAD file '%s' not found!", iwadfile); } *mission = IdentifyIWADByName(result, mask); } else { // Search through the list and look for an IWAD result = NULL; BuildIWADDirList(); for (i=0; result == NULL && i<num_iwad_dirs; ++i) { result = SearchDirectoryForIWAD(iwad_dirs[i], mask, mission); } } return result; }
char *D_FindWADByName(char *name) { char *buf; int i; // Absolute path? if (M_FileExists(name)) { return name; } BuildIWADDirList(); // Search through all IWAD paths for a file with the given name. for (i=0; i<num_iwad_dirs; ++i) { // As a special case, if this is in DOOMWADDIR or DOOMWADPATH, // the "directory" may actually refer directly to an IWAD // file. if (DirIsFile(iwad_dirs[i], name) && M_FileExists(iwad_dirs[i])) { return strdup(iwad_dirs[i]); } // Construct a string for the full path buf = malloc(strlen(iwad_dirs[i]) + strlen(name) + 5); sprintf(buf, "%s%c%s", iwad_dirs[i], DIR_SEPARATOR, name); if (M_FileExists(buf)) { return buf; } free(buf); } // File not found return NULL; }
void D_FindInstalledIWADs(void) { uint32_t i; int32_t result; BuildIWADDirList(); result = 0; for (i=0; i<arrlen(iwads); ++i) { if (D_FindWADByName(iwads[i].name) != NULL) { result |= 1 << i; } } exit(result); }