MCPcopy Index your code
hub / github.com/assaultcube/AC / addcomplete

Function addcomplete

source/src/command.cpp:776–812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774static hashtable<char *, completeval *> completions;
775
776void addcomplete(char *command, int type, char *dir, char *ext)
777{
778 if(type==COMPLETE_FILE)
779 {
780 int dirlen = (int)strlen(dir);
781 while(dirlen > 0 && (dir[dirlen-1] == '/' || dir[dirlen-1] == '\\'))
782 dir[--dirlen] = '\0';
783 if(ext)
784 {
785 if(strchr(ext, '*')) ext[0] = '\0';
786 if(!ext[0]) ext = NULL;
787 }
788 }
789 completekey key(type, dir, ext);
790 completeval **val = completedata.access(key);
791 if(!val)
792 {
793 completeval *f = new completeval(type, dir, ext);
794 if(type==COMPLETE_LIST) explodelist(dir, f->list);
795 if(type==COMPLETE_FILE)
796 {
797 explodelist(dir, f->dirlist);
798 loopv(f->dirlist)
799 {
800 char *dir = f->dirlist[i];
801 int dirlen = (int)strlen(dir);
802 while(dirlen > 0 && (dir[dirlen-1] == '/' || dir[dirlen-1] == '\\'))
803 dir[--dirlen] = '\0';
804 }
805 }
806 val = &completedata[completekey(type, f->dir, f->ext)];
807 *val = f;
808 }
809 completeval **hascomplete = completions.access(command);
810 if(hascomplete) *hascomplete = *val;
811 else completions[newstring(command)] = *val;
812}
813
814void addfilecomplete(char *command, char *dir, char *ext)
815{

Callers 3

addfilecompleteFunction · 0.85
addlistcompleteFunction · 0.85
addnickcompleteFunction · 0.85

Calls 5

explodelistFunction · 0.85
completekeyClass · 0.85
newstringFunction · 0.85
accessMethod · 0.80
loopvFunction · 0.70

Tested by

no test coverage detected