* PROFILE_FlushFile * * Flush the current profile to disk if changed. ***********************************************************************/
| 351 | * Flush the current profile to disk if changed. |
| 352 | ***********************************************************************/ |
| 353 | static BOOL PROFILE_FlushFile(void) |
| 354 | { |
| 355 | //char *p, buffer[MAX_PATHNAME_LEN]; |
| 356 | //const char *unix_name; |
| 357 | FILE *file = NULL; |
| 358 | struct stat buf; |
| 359 | |
| 360 | if (trace(2)) |
| 361 | htrc("PROFILE_FlushFile: CurProfile=%p\n", CurProfile); |
| 362 | |
| 363 | if (!CurProfile) { |
| 364 | fprintf(stderr, "No current profile!\n"); |
| 365 | return FALSE; |
| 366 | } // endif !CurProfile |
| 367 | |
| 368 | if (!CurProfile->changed || !CurProfile->filename) |
| 369 | return TRUE; |
| 370 | |
| 371 | #if 0 |
| 372 | if (!(file = fopen(unix_name, "w"))) { |
| 373 | /* Try to create it in $HOME/.wine */ |
| 374 | /* FIXME: this will need a more general solution */ |
| 375 | //strcpy( buffer, get_config_dir() ); |
| 376 | //p = buffer + strlen(buffer); |
| 377 | //*p++ = '/'; |
| 378 | char *p1 = strrchr(CurProfile->filename, '\\'); |
| 379 | |
| 380 | p = buffer; // OB: To be elaborate |
| 381 | |
| 382 | if (p1) |
| 383 | p1++; |
| 384 | else |
| 385 | p1 = CurProfile->dos_name; |
| 386 | |
| 387 | strcpy(p, p1); |
| 388 | _strlwr(p); |
| 389 | file = fopen(buffer, "w"); |
| 390 | unix_name = buffer; |
| 391 | } // endif !unix_name |
| 392 | #endif // 0 |
| 393 | |
| 394 | if (!(file = fopen(CurProfile->filename, "w"))) { |
| 395 | fprintf(stderr, "could not save profile file %s\n", CurProfile->filename); |
| 396 | return FALSE; |
| 397 | } // endif !file |
| 398 | |
| 399 | if (trace(2)) |
| 400 | htrc("Saving '%s'\n", CurProfile->filename); |
| 401 | |
| 402 | PROFILE_Save(file, CurProfile->section); |
| 403 | fclose(file); |
| 404 | CurProfile->changed = FALSE; |
| 405 | |
| 406 | if (!stat(CurProfile->filename, &buf)) |
| 407 | CurProfile->mtime = buf.st_mtime; |
| 408 | |
| 409 | return TRUE; |
| 410 | } // end of PROFILE_FlushFile |
no test coverage detected