// reads all pak files from a dir void vfsInitDirectory(const char *path) { char filename[PATH_MAX]; char *dirlist; GDir *dir; if(g_numDirs == (VFS_MAXDIRS - 1)) return; Sys_Printf("VFS Init: %s\n", path); strcpy(g_strDirs[g_numDirs], path); vfsFixDOSName(g_strDirs[g_numDirs]); vfsAddSlash(g_strDirs[g_numDirs]); g_numDirs++; if(g_bUsePak) { dir = g_dir_open(path, 0, NULL); if(dir != NULL) { while(1) { const char *name = g_dir_read_name(dir); if(name == NULL) break; dirlist = g_strdup(name); { char *ext = strrchr(dirlist, '.'); if(ext && !Q_stricmp(ext, ".pk3dir")) { if(g_numDirs == VFS_MAXDIRS) continue; //snprintf(g_strDirs[g_numDirs], PATH_MAX, "%s/%s", path, name); sprintf(g_strDirs[g_numDirs], "%s/%s", path, name); Sys_Printf("VFS Init: %s (pk3dir)\n", g_strDirs[g_numDirs]); g_strDirs[g_numDirs][PATH_MAX] = '\0'; vfsFixDOSName (g_strDirs[g_numDirs]); vfsAddSlash (g_strDirs[g_numDirs]); ++g_numDirs; } if((ext == NULL) || (Q_stricmp(ext, ".pk3") != 0)) continue; } sprintf(filename, "%s/%s", path, dirlist); vfsInitPakFile(filename); g_free(dirlist); } g_dir_close(dir); } } }
void vfsInitDirectory (const char *path) { char filename[PATH_MAX]; //struct dirent *direntry; GDir *dir; GSList *dirlist = NULL; if (g_numDirs == (VFS_MAXDIRS-1)) return; strcpy (g_strDirs[g_numDirs], path); vfsFixDOSName (g_strDirs[g_numDirs]); vfsAddSlash (g_strDirs[g_numDirs]); g_numDirs++; if (g_bUsePak) { dir = g_dir_open (path, 0, NULL); if (dir != NULL) { g_FuncTable.m_pfnSysPrintf("vfs directory: %s\n", path); for(;;) { const char* name = g_dir_read_name(dir); if(name == NULL) break; char *ext = strrchr (name, '.'); if ((ext == NULL) || (strcasecmp (ext, ".pak") != 0)) continue; char* direntry = g_strdup(name); dirlist = g_slist_append (dirlist, direntry); } g_dir_close (dir); // sort them dirlist = g_slist_sort (dirlist, vfsPakSort); // add the entries to the vfs and free the list while (dirlist) { GSList *cur = dirlist; char* name = (char*)cur->data; sprintf (filename, "%s/%s", path, name); vfsInitPakFile (filename); g_free (name); dirlist = g_slist_remove (cur, name); } } else g_FuncTable.m_pfnSysFPrintf(SYS_WRN, "vfs directory not found: %s\n", path); } }
// reads all pak files from a dir void vfsInitDirectory( const char *path ){ char filename[PATH_MAX]; if ( g_numDirs == ( VFS_MAXDIRS - 1 ) ) { return; } strcpy( g_strDirs[g_numDirs], path ); vfsFixDOSName( g_strDirs[g_numDirs] ); vfsAddSlash( g_strDirs[g_numDirs] ); g_numDirs++; // if (g_PrefsDlg.m_bPAK) // TODO: can't read prefs from a module, bah.. if ( 1 ) { GDir* dir = g_dir_open( path, 0, NULL ); if ( dir != NULL ) { g_FuncTable.m_pfnSysPrintf( "vfs directory: %s\n", path ); while ( 1 ) { const char* name = g_dir_read_name( dir ); if ( name == NULL ) { break; } const char *ext = strrchr( name, '.' ); if ( ( ext == NULL ) || ( strcmp( ext, ".wad" ) != 0 ) ) { continue; } sprintf( filename, "%s/%s", path, name ); vfsInitPakFile( filename ); } g_dir_close( dir ); } else{ g_FuncTable.m_pfnSysFPrintf( SYS_WRN, "vfs directory not found: %s\n", path ); } } }
/*! The gamemode hacks in here will do undefined things with files called zz_*. This is simple to fix by cleaning up the hacks, but may be better left alone if the engine code does the same thing. */ void vfsInitDirectory( const char *path ){ char filename[PATH_MAX]; GDir *dir; GSList *dirlist = NULL; int iGameMode; // 0: no filtering 1: SP 2: MP if ( g_numDirs == ( VFS_MAXDIRS - 1 ) ) { return; } // See if we are in "sp" or "mp" mapping mode const char* gamemode = g_FuncTable.m_pfnReadProjectKey( "gamemode" ); if ( gamemode ) { if ( strcmp( gamemode, "sp" ) == 0 ) { iGameMode = 1; } else if ( strcmp( gamemode, "mp" ) == 0 ) { iGameMode = 2; } else{ iGameMode = 0; } } else{ iGameMode = 0; } strcpy( g_strDirs[g_numDirs], path ); vfsFixDOSName( g_strDirs[g_numDirs] ); vfsAddSlash( g_strDirs[g_numDirs] ); g_numDirs++; if ( g_bUsePak ) { dir = g_dir_open( path, 0, NULL ); if ( dir != NULL ) { g_FuncTable.m_pfnSysPrintf( "vfs directory: %s\n", path ); for (;; ) { const char* name = g_dir_read_name( dir ); if ( name == NULL ) { break; } char *ext = (char*)strrchr( name, '.' ); if ( ( ext == NULL ) || ( strcasecmp( ext, ".pk3" ) != 0 ) ) { continue; } char* direntry = g_strdup( name ); // using the same kludge as in engine to ensure consistency switch ( iGameMode ) { case 1: // SP if ( strncmp( direntry,"sp_",3 ) == 0 ) { memcpy( direntry,"zz",2 ); } break; case 2: // MP if ( strncmp( direntry,"mp_",3 ) == 0 ) { memcpy( direntry,"zz",2 ); } break; } dirlist = g_slist_append( dirlist, direntry ); } g_dir_close( dir ); // sort them dirlist = g_slist_sort( dirlist, vfsPakSort ); // add the entries to the vfs and free the list while ( dirlist ) { GSList *cur = dirlist; char* name = (char*)cur->data; switch ( iGameMode ) { case 1: // SP if ( strncmp( name,"mp_",3 ) == 0 ) { g_free( name ); dirlist = g_slist_remove( cur, name ); continue; } else if ( strncmp( name,"zz_",3 ) == 0 ) { memcpy( name,"sp",2 ); } break; case 2: // MP if ( strncmp( name,"sp_",3 ) == 0 ) { g_free( name ); dirlist = g_slist_remove( cur, name ); continue; } else if ( strncmp( name,"zz_",3 ) == 0 ) { memcpy( name,"mp",2 ); } break; } sprintf( filename, "%s/%s", path, name ); vfsInitPakFile( filename ); g_free( name ); dirlist = g_slist_remove( cur, name ); } } else{ g_FuncTable.m_pfnSysFPrintf( SYS_WRN, "vfs directory not found: %s\n", path ); } } }