=========== idFileSystemLocal::OpenFileWrite =========== */
| 3203 | =========== |
| 3204 | */ |
| 3205 | idFile *idFileSystemLocal::OpenFileWrite( const char *relativePath, const char *basePath ) { |
| 3206 | const char *path; |
| 3207 | idStr OSpath; |
| 3208 | idFile_Permanent *f; |
| 3209 | |
| 3210 | if ( !searchPaths ) { |
| 3211 | common->FatalError( "Filesystem call made without initialization\n" ); |
| 3212 | } |
| 3213 | |
| 3214 | path = cvarSystem->GetCVarString( basePath ); |
| 3215 | if ( !path[0] ) { |
| 3216 | path = fs_savepath.GetString(); |
| 3217 | } |
| 3218 | |
| 3219 | OSpath = BuildOSPath( path, gameFolder, relativePath ); |
| 3220 | |
| 3221 | if ( fs_debug.GetInteger() ) { |
| 3222 | common->Printf( "idFileSystem::OpenFileWrite: %s\n", OSpath.c_str() ); |
| 3223 | } |
| 3224 | |
| 3225 | // if the dir we are writing to is in our current list, it will be outdated |
| 3226 | // so just flush everything |
| 3227 | ClearDirCache(); |
| 3228 | |
| 3229 | common->DPrintf( "writing to: %s\n", OSpath.c_str() ); |
| 3230 | CreateOSPath( OSpath ); |
| 3231 | |
| 3232 | f = new idFile_Permanent(); |
| 3233 | f->o = OpenOSFile( OSpath, "wb" ); |
| 3234 | if ( !f->o ) { |
| 3235 | delete f; |
| 3236 | return NULL; |
| 3237 | } |
| 3238 | f->name = relativePath; |
| 3239 | f->fullPath = OSpath; |
| 3240 | f->mode = ( 1 << FS_WRITE ); |
| 3241 | f->handleSync = false; |
| 3242 | f->fileSize = 0; |
| 3243 | |
| 3244 | return f; |
| 3245 | } |
| 3246 | |
| 3247 | /* |
| 3248 | =========== |
no test coverage detected