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