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

Function FS_CreatePath

code/qcommon/files.cpp:486–518  ·  view source on GitHub ↗

============ FS_CreatePath Creates any directories needed to store the given filename ============ */

Source from the content-addressed store, hash-verified

484============
485*/
486qboolean FS_CreatePath (char *OSPath) {
487 char *ofs;
488 char path[MAX_OSPATH];
489
490 // make absolutely sure that it can't back up the path
491 // FIXME: is c: allowed???
492 if ( strstr( OSPath, ".." ) || strstr( OSPath, "::" ) ) {
493 Com_Printf( "WARNING: refusing to create relative path \"%s\"\n", OSPath );
494 return qtrue;
495 }
496
497 Q_strncpyz( path, OSPath, sizeof( path ) );
498 FS_ReplaceSeparators( path );
499
500 // Skip creation of the root directory as it will always be there
501 ofs = strchr( path, PATH_SEP );
502 if ( ofs ) {
503 ofs++;
504 }
505
506 for (; ofs != NULL && *ofs ; ofs++) {
507 if (*ofs == PATH_SEP) {
508 // create the directory
509 *ofs = 0;
510 if (!Sys_Mkdir (path)) {
511 Com_Error( ERR_FATAL, "FS_CreatePath: failed to create path \"%s\"",
512 path );
513 }
514 *ofs = PATH_SEP;
515 }
516 }
517 return qfalse;
518}
519
520/*
521=================

Callers 6

FS_CopyFileFunction · 0.70
FS_SV_FOpenFileWriteFunction · 0.70
FS_FOpenFileWriteFunction · 0.70
FS_FOpenFileAppendFunction · 0.70
FS_FOpenFileReadFunction · 0.70
FS_StartupFunction · 0.70

Calls 5

Q_strncpyzFunction · 0.85
Com_PrintfFunction · 0.70
FS_ReplaceSeparatorsFunction · 0.70
Com_ErrorFunction · 0.70
Sys_MkdirFunction · 0.50

Tested by

no test coverage detected