MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / GetFileList

Method GetFileList

neo/framework/FileSystem.cpp:1479–1615  ·  view source on GitHub ↗

=============== idFileSystemLocal::GetFileList Does not clear the list first so this can be used to progressively build a file list. When 'sort' is true only the new files added to the list are sorted. =============== */

Source from the content-addressed store, hash-verified

1477===============
1478*/
1479int idFileSystemLocal::GetFileList( const char *relativePath, const idStrList &extensions, idStrList &list, idHashIndex &hashIndex, bool fullRelativePath, const char* gamedir ) {
1480 searchpath_t * search;
1481 fileInPack_t * buildBuffer;
1482 int i, j;
1483 int pathLength;
1484 int length;
1485 const char * name;
1486 pack_t * pak;
1487 idStr work;
1488
1489 if ( !searchPaths ) {
1490 common->FatalError( "Filesystem call made without initialization\n" );
1491 }
1492
1493 if ( !extensions.Num() ) {
1494 return 0;
1495 }
1496
1497 if ( !relativePath ) {
1498 return 0;
1499 }
1500 pathLength = strlen( relativePath );
1501 if ( pathLength ) {
1502 pathLength++; // for the trailing '/'
1503 }
1504
1505 // search through the path, one element at a time, adding to list
1506 for( search = searchPaths; search != NULL; search = search->next ) {
1507 if ( search->dir ) {
1508 if(gamedir && strlen(gamedir)) {
1509 if(search->dir->gamedir != gamedir) {
1510 continue;
1511 }
1512 }
1513
1514 idStrList sysFiles;
1515 idStr netpath;
1516
1517 netpath = BuildOSPath( search->dir->path, search->dir->gamedir, relativePath );
1518
1519 for ( i = 0; i < extensions.Num(); i++ ) {
1520
1521 // scan for files in the filesystem
1522 ListOSFiles( netpath, extensions[i], sysFiles );
1523
1524 // if we are searching for directories, remove . and ..
1525 if ( extensions[i][0] == '/' && extensions[i][1] == 0 ) {
1526 sysFiles.Remove( "." );
1527 sysFiles.Remove( ".." );
1528 }
1529
1530 for( j = 0; j < sysFiles.Num(); j++ ) {
1531 // unique the match
1532 if ( fullRelativePath ) {
1533 work = relativePath;
1534 work += "/";
1535 work += sysFiles[j];
1536 AddUnique( work, list, hashIndex );

Callers

nothing calls this directly

Calls 7

StripTrailingMethod · 0.80
IcmpMethod · 0.60
FatalErrorMethod · 0.45
NumMethod · 0.45
RemoveMethod · 0.45
FindMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected