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

Function FS_CreatePath

codemp/qcommon/files.cpp:532–564  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

530============
531*/
532qboolean FS_CreatePath (char *OSPath) {
533 char *ofs;
534 char path[MAX_OSPATH];
535
536 // make absolutely sure that it can't back up the path
537 // FIXME: is c: allowed???
538 if ( strstr( OSPath, ".." ) || strstr( OSPath, "::" ) ) {
539 Com_Printf( "WARNING: refusing to create relative path \"%s\"\n", OSPath );
540 return qtrue;
541 }
542
543 Q_strncpyz( path, OSPath, sizeof( path ) );
544 FS_ReplaceSeparators( path );
545
546 // Skip creation of the root directory as it will always be there
547 ofs = strchr( path, PATH_SEP );
548 if ( ofs ) {
549 ofs++;
550 }
551
552 for (; ofs != NULL && *ofs ; ofs++) {
553 if (*ofs == PATH_SEP) {
554 // create the directory
555 *ofs = 0;
556 if (!Sys_Mkdir (path)) {
557 Com_Error( ERR_FATAL, "FS_CreatePath: failed to create path \"%s\"",
558 path );
559 }
560 *ofs = PATH_SEP;
561 }
562 }
563 return qfalse;
564}
565
566/*
567=================

Callers 7

FS_CopyFileFunction · 0.70
FS_SV_FOpenFileWriteFunction · 0.70
FS_SV_FOpenFileAppendFunction · 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