/* ========== OGG_Shutdown Shutdown the Ogg Vorbis subsystem. ========== */ void OGG_Shutdown(void) { if (!ogg_started) return; Com_Printf("Shutting down Ogg Vorbis.\n"); OGG_Stop(); /* Free the list of files. */ FS_FreeList(ogg_filelist, ogg_numfiles + 1); /* Remove console commands. */ Cmd_RemoveCommand("ogg_list"); Cmd_RemoveCommand("ogg_pause"); Cmd_RemoveCommand("ogg_play"); Cmd_RemoveCommand("ogg_reinit"); Cmd_RemoveCommand("ogg_resume"); Cmd_RemoveCommand("ogg_seek"); Cmd_RemoveCommand("ogg_status"); Cmd_RemoveCommand("ogg_stop"); ogg_started = false; }
static int copy_save_dir(const char *src, const char *dst) { void **list; int i, count, ret = 0; if ((list = list_save_dir(src, &count)) == NULL) return -1; for (i = 0; i < count; i++) ret |= copy_file(src, dst, list[i]); FS_FreeList(list); return ret; }
static int wipe_save_dir(const char *dir) { void **list; int i, count, ret = 0; if ((list = list_save_dir(dir, &count)) == NULL) return 0; for (i = 0; i < count; i++) ret |= remove_file(dir, list[i]); FS_FreeList(list); return ret; }
/* * Directory listing. */ void FS_Dir_f(void) { char **dirnames; /* File list. */ char findname[1024]; /* File search path and pattern. */ char *path = NULL; /* Search path. */ char wildcard[1024] = "*.*"; /* File pattern. */ int i; /* Loop counter. */ int ndirs; /* Number of files in list. */ /* Check for pattern in arguments. */ if (Cmd_Argc() != 1) { Q_strlcpy(wildcard, Cmd_Argv(1), sizeof(wildcard)); } /* Scan search paths and list files. */ while ((path = FS_NextPath(path)) != NULL) { Com_sprintf(findname, sizeof(findname), "%s/%s", path, wildcard); Com_Printf("Directory of '%s'.\n", findname); Com_Printf("----\n"); if ((dirnames = FS_ListFiles(findname, &ndirs, 0, 0)) != 0) { for (i = 0; i < ndirs - 1; i++) { if (strrchr(dirnames[i], '/')) { Com_Printf("%s\n", strrchr(dirnames[i], '/') + 1); } else { Com_Printf("%s\n", dirnames[i]); } } FS_FreeList(dirnames, ndirs); } Com_Printf("\n"); } }
/* * Adds the directory to the head of the path, then loads and adds pak1.pak * pak2.pak ... * * Extended all functionality to include Quake III .pk3 */ void FS_AddGameDirectory(const char *dir) { char **list; /* File list. */ char path[MAX_OSPATH]; /* Path to PAK / PK3. */ int i, j; /* Loop counters. */ int nfiles; /* Number of files in list. */ fsSearchPath_t *search; /* Search path. */ fsPack_t *pack; /* PAK / PK3 file. */ pack = NULL; /* Set game directory. */ Q_strlcpy(fs_gamedir, dir, sizeof(fs_gamedir)); /* Create directory if it does not exist. */ FS_CreatePath(fs_gamedir); /* Add the directory to the search path. */ search = Z_Malloc(sizeof(fsSearchPath_t)); Q_strlcpy(search->path, dir, sizeof(search->path)); search->next = fs_searchPaths; fs_searchPaths = search; /* Add numbered pack files in sequence. */ for (i = 0; i < sizeof(fs_packtypes) / sizeof(fs_packtypes[0]); i++) { for (j = 0; j < MAX_PAKS; j++) { Com_sprintf(path, sizeof(path), "%s/pak%d.%s", dir, j, fs_packtypes[i].suffix); switch (fs_packtypes[i].format) { case PAK: pack = FS_LoadPAK(path); break; #ifdef ZIP case PK3: pack = FS_LoadPK3(path); break; #endif } if (pack == NULL) { continue; } search = Z_Malloc(sizeof(fsSearchPath_t)); search->pack = pack; search->next = fs_searchPaths; fs_searchPaths = search; } } /* Add not numbered pack files. */ for (i = 0; i < sizeof(fs_packtypes) / sizeof(fs_packtypes[0]); i++) { Com_sprintf(path, sizeof(path), "%s/*.%s", dir, fs_packtypes[i].suffix); if ((list = FS_ListFiles(path, &nfiles, 0, SFF_SUBDIR)) == NULL) { continue; } Com_sprintf(path, sizeof(path), "%s/pak*.%s", dir, fs_packtypes[i].suffix); for (j = 0; j < nfiles - 1; j++) { /* Skip numbered packs. */ if (glob_match(path, list[j])) { continue; } switch (fs_packtypes[i].format) { case PAK: pack = FS_LoadPAK(list[j]); break; #ifdef ZIP case PK3: pack = FS_LoadPK3(list[j]); break; #endif } if (pack == NULL) { continue; } search = Z_Malloc(sizeof(fsSearchPath_t)); search->pack = pack; search->next = fs_searchPaths; fs_searchPaths = search; } FS_FreeList(list, nfiles); } }
static void BuildList( void ) { int numDirs, numDemos; void **dirlist, **demolist; char *cache, *p; unsigned flags; size_t len; int i; // this can be a lengthy process S_StopAllSounds(); m_demos.menu.status = "Building list..."; SCR_UpdateScreen(); // list files flags = ui_listalldemos->integer ? 0 : FS_TYPE_REAL | FS_PATH_GAME; dirlist = FS_ListFiles( m_demos.browse, NULL, flags | FS_SEARCH_DIRSONLY, &numDirs ); demolist = FS_ListFiles( m_demos.browse, DEMO_EXTENSIONS, flags | FS_SEARCH_EXTRAINFO, &numDemos ); // alloc entries m_demos.list.items = UI_Malloc( sizeof( demoEntry_t * ) * ( numDirs + numDemos + 1 ) ); m_demos.list.numItems = 0; m_demos.list.curvalue = 0; m_demos.list.prestep = 0; m_demos.widest_map = 3; m_demos.widest_pov = 3; m_demos.total_bytes = 0; // start with minimum size m_demos.menu.size( &m_demos.menu ); if( m_demos.browse[0] ) { BuildDir( "..", ENTRY_UP ); } // add directories if( dirlist ) { for( i = 0; i < numDirs; i++ ) { BuildDir( dirlist[i], ENTRY_DN ); } FS_FreeList( dirlist ); } m_demos.numDirs = m_demos.list.numItems; // add demos if( demolist ) { CalcHash( demolist ); if( ( cache = LoadCache( demolist ) ) != NULL ) { p = cache + 32 + 1; for( i = 0; i < numDemos; i++ ) { BuildName( demolist[i], &p ); } FS_FreeFile( cache ); } else { for( i = 0; i < numDemos; i++ ) { BuildName( demolist[i], NULL ); if( ( i & 7 ) == 0 ) { m_demos.menu.size( &m_demos.menu ); SCR_UpdateScreen(); } } } WriteCache(); FS_FreeList( demolist ); } // update status line and sort if( m_demos.list.numItems ) { Change( &m_demos.list.generic ); if( m_demos.list.sortdir ) { m_demos.list.sort( &m_demos.list, m_demos.list.sortcol ); } } // resize columns m_demos.menu.size( &m_demos.menu ); // format our extra status line i = m_demos.list.numItems - m_demos.numDirs; len = Q_scnprintf( m_demos.status, sizeof( m_demos.status ), "%d demo%s, ", i, i == 1 ? "" : "s" ); Com_FormatSizeLong( m_demos.status + len, sizeof( m_demos.status ) - len, m_demos.total_bytes ); SCR_UpdateScreen(); }
void PlayerModel_Load(void) { char scratch[MAX_QPATH]; size_t len; int ndirs = 0; char *dirnames[MAX_PLAYERMODELS]; int i, j; char **list; char *s, *p; int numFiles; playerModelInfo_t *pmi; uis.numPlayerModels = 0; // get a list of directories if (!(list = (char **)FS_ListFiles(NULL, "players/*/tris.md2", FS_SEARCH_BYFILTER | FS_SEARCH_SAVEPATH, &numFiles))) { return; } for (i = 0; i < numFiles; i++) { len = Q_strlcpy(scratch, list[i], sizeof(scratch)); if (len >= sizeof(scratch)) continue; // make short name for the model if (!(s = strchr(scratch, '/'))) continue; s++; if (!(p = strchr(s, '/'))) continue; *p = 0; for (j = 0; j < ndirs; j++) { if (!strcmp(dirnames[j], s)) { break; } } if (j != ndirs) { continue; } dirnames[ndirs++] = UI_CopyString(s); if (ndirs == MAX_PLAYERMODELS) { break; } } FS_FreeList((void **)list); if (!ndirs) { return; } // go through the subdirectories for (i = 0; i < ndirs; i++) { int k, s; char **pcxnames; char **skinnames; int npcxfiles; int nskins = 0; // verify the existence of tris.md2 Q_concat(scratch, sizeof(scratch), "players/", dirnames[i], "/tris.md2", NULL); if (!FS_FileExists(scratch)) { goto skip; } // verify the existence of at least one pcx skin Q_concat(scratch, sizeof(scratch), "players/", dirnames[i], NULL); pcxnames = (char **)FS_ListFiles(scratch, ".pcx", 0, &npcxfiles); if (!pcxnames) { goto skip; } // count valid skins, which consist of a skin with a matching "_i" icon for (k = 0; k < npcxfiles; k++) { if (!strstr(pcxnames[k], "_i.pcx")) { if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles)) { nskins++; } } } if (!nskins) { FS_FreeList((void **)pcxnames); goto skip; } skinnames = UI_Malloc(sizeof(char *) * (nskins + 1)); skinnames[nskins] = NULL; // copy the valid skins for (s = 0, k = 0; k < npcxfiles; k++) { if (!strstr(pcxnames[k], "_i.pcx")) { if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles)) { COM_StripExtension(scratch, pcxnames[k], sizeof(scratch)); skinnames[s++] = UI_CopyString(scratch); } } } FS_FreeList((void **)pcxnames); // at this point we have a valid player model pmi = &uis.pmi[uis.numPlayerModels++]; pmi->nskins = nskins; pmi->skindisplaynames = skinnames; pmi->directory = dirnames[i]; continue; skip: Z_Free(dirnames[i]); } qsort(uis.pmi, uis.numPlayerModels, sizeof(uis.pmi[0]), pmicmpfnc); }