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

Method ArgCompletion_FolderExtension

neo/framework/CmdSystem.cpp:688–747  ·  view source on GitHub ↗

============ idCmdSystemLocal::ArgCompletion_FolderExtension ============ */

Source from the content-addressed store, hash-verified

686============
687*/
688void idCmdSystemLocal::ArgCompletion_FolderExtension( const idCmdArgs &args, void(*callback)( const char *s ), const char *folder, bool stripFolder, ... ) {
689 int i;
690 idStr string;
691 const char *extension;
692 va_list argPtr;
693
694 string = args.Argv( 0 );
695 string += " ";
696 string += args.Argv( 1 );
697
698 if ( string.Icmp( completionString ) != 0 ) {
699 idStr parm, path;
700 idFileList *names;
701
702 completionString = string;
703 completionParms.Clear();
704
705 parm = args.Argv( 1 );
706 parm.ExtractFilePath( path );
707 if ( stripFolder || path.Length() == 0 ) {
708 path = folder + path;
709 }
710 path.StripTrailing( '/' );
711
712 // list folders
713 names = fileSystem->ListFiles( path, "/", true, true );
714 for ( i = 0; i < names->GetNumFiles(); i++ ) {
715 idStr name = names->GetFile( i );
716 if ( stripFolder ) {
717 name.Strip( folder );
718 } else {
719 name.Strip( "/" );
720 }
721 name = args.Argv( 0 ) + ( " " + name ) + "/";
722 completionParms.Append( name );
723 }
724 fileSystem->FreeFileList( names );
725
726 // list files
727 va_start( argPtr, stripFolder );
728 for ( extension = va_arg( argPtr, const char * ); extension; extension = va_arg( argPtr, const char * ) ) {
729 names = fileSystem->ListFiles( path, extension, true, true );
730 for ( i = 0; i < names->GetNumFiles(); i++ ) {
731 idStr name = names->GetFile( i );
732 if ( stripFolder ) {
733 name.Strip( folder );
734 } else {
735 name.Strip( "/" );
736 }
737 name = args.Argv( 0 ) + ( " " + name );
738 completionParms.Append( name );
739 }
740 fileSystem->FreeFileList( names );
741 }
742 va_end( argPtr );
743 }
744 for ( i = 0; i < completionParms.Num(); i++ ) {
745 callback( completionParms[i] );

Callers 13

ArgCompletion_DefFileFunction · 0.80
ArgCompletion_MapNameMethod · 0.80

Calls 13

ArgvMethod · 0.80
ExtractFilePathMethod · 0.80
StripTrailingMethod · 0.80
ListFilesMethod · 0.80
GetNumFilesMethod · 0.80
GetFileMethod · 0.80
StripMethod · 0.80
FreeFileListMethod · 0.80
IcmpMethod · 0.60
ClearMethod · 0.45
LengthMethod · 0.45
AppendMethod · 0.45

Tested by 2