=========== FS_FOpenFileWrite =========== */
| 1000 | =========== |
| 1001 | */ |
| 1002 | fileHandle_t FS_FOpenFileWrite( const char *filename, qboolean safe ) { |
| 1003 | char *ospath; |
| 1004 | fileHandle_t f; |
| 1005 | |
| 1006 | FS_AssertInitialised(); |
| 1007 | |
| 1008 | f = FS_HandleForFile(); |
| 1009 | fsh[f].zipFile = qfalse; |
| 1010 | |
| 1011 | ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, filename ); |
| 1012 | |
| 1013 | if ( fs_debug->integer ) { |
| 1014 | Com_Printf( "FS_FOpenFileWrite: %s\n", ospath ); |
| 1015 | } |
| 1016 | |
| 1017 | if ( safe ) { |
| 1018 | FS_CheckFilenameIsMutable( ospath, __func__ ); |
| 1019 | } |
| 1020 | |
| 1021 | if( FS_CreatePath( ospath ) ) { |
| 1022 | return 0; |
| 1023 | } |
| 1024 | |
| 1025 | // enabling the following line causes a recursive function call loop |
| 1026 | // when running with +set logfile 1 +set developer 1 |
| 1027 | //Com_DPrintf( "writing to: %s\n", ospath ); |
| 1028 | fsh[f].handleFiles.file.o = fopen( ospath, "wb" ); |
| 1029 | |
| 1030 | Q_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) ); |
| 1031 | |
| 1032 | fsh[f].handleSync = qfalse; |
| 1033 | if (!fsh[f].handleFiles.file.o) { |
| 1034 | f = 0; |
| 1035 | } |
| 1036 | return f; |
| 1037 | } |
| 1038 | |
| 1039 | /* |
| 1040 | =========== |
no test coverage detected