MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Cmd_Exec_f

Function Cmd_Exec_f

code/qcommon/cmd.cpp:270–299  ·  view source on GitHub ↗

=============== Cmd_Exec_f =============== */

Source from the content-addressed store, hash-verified

268===============
269*/
270void Cmd_Exec_f( void ) {
271 bool quiet;
272 union {
273 char *c;
274 void *v;
275 } f;
276 char filename[MAX_QPATH];
277
278 quiet = !Q_stricmp(Cmd_Argv(0), "execq");
279
280 if (Cmd_Argc () != 2) {
281 Com_Printf ("exec%s <filename> : execute a script file%s\n",
282 quiet ? "q" : "", quiet ? " without notification" : "");
283 return;
284 }
285
286 Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );
287 COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
288 FS_ReadFile( filename, &f.v);
289 if (!f.c) {
290 Com_Printf ("couldn't exec %s\n", filename);
291 return;
292 }
293 if (!quiet)
294 Com_Printf ("execing %s\n", filename);
295
296 Cbuf_InsertText (f.c);
297
298 FS_FreeFile (f.v);
299}
300
301
302/*

Callers

nothing calls this directly

Calls 9

Q_stricmpFunction · 0.85
Q_strncpyzFunction · 0.85
Cmd_ArgvFunction · 0.70
Cmd_ArgcFunction · 0.70
Com_PrintfFunction · 0.70
COM_DefaultExtensionFunction · 0.70
FS_ReadFileFunction · 0.70
Cbuf_InsertTextFunction · 0.70
FS_FreeFileFunction · 0.70

Tested by

no test coverage detected