============ FS_CreatePath Creates any directories needed to store the given filename ============ */
| 484 | ============ |
| 485 | */ |
| 486 | qboolean 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 | ================= |
no test coverage detected