Changeset 529 for trunk/src/kernel32/profile.cpp
- Timestamp:
- Aug 17, 1999, 6:35:30 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/profile.cpp
r436 r529 1 /* $Id: profile.cpp,v 1. 8 1999-08-06 12:14:12phaller Exp $ */1 /* $Id: profile.cpp,v 1.9 1999-08-17 16:35:10 phaller Exp $ */ 2 2 3 3 /* … … 10 10 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) 11 11 * Copyright 1998 Patrick Haller 12 * Copyright 1999 Christoph Bratschi 12 13 */ 13 14 … … 63 64 BOOL changed; 64 65 PROFILESECTION *section; 65 char *filename; 66 char *filename; //first open name 67 char *fullname; //name with path 66 68 time_t mtime; 67 69 } PROFILE; … … 79 81 80 82 #define PROFILE_MAX_LINE_LEN 1024 83 #define WINININAME "WIN.INI" 81 84 82 85 /* Wine profile name in $HOME directory; must begin with slash */ … … 91 94 #define WINE_INI_GLOBAL ETCDIR "/wine.conf" 92 95 93 static LPCWSTR wininiW = NULL; 96 static LPCWSTR wininiW = NULL; //CB: never freed 94 97 95 98 static CRITICAL_SECTION PROFILE_CritSect; … … 398 401 399 402 // try to open file 400 file = fopen(CurProfile->f ilename, "w");403 file = fopen(CurProfile->fullname, "w"); 401 404 if (!file) 402 405 { 403 dprintf(("Kernel32:Profile:could not save profile file %s\n", CurProfile->f ilename));406 dprintf(("Kernel32:Profile:could not save profile file %s\n", CurProfile->fullname)); 404 407 return FALSE; 405 408 } 406 409 407 dprintf(("Kernel32:Profile:Saving %s\n", CurProfile->f ilename ));410 dprintf(("Kernel32:Profile:Saving %s\n", CurProfile->fullname )); 408 411 PROFILE_Save( file, CurProfile->section ); 409 412 fclose( file ); 410 413 CurProfile->changed = FALSE; 411 if(!stat(CurProfile->f ilename,&buf))414 if(!stat(CurProfile->fullname,&buf)) 412 415 CurProfile->mtime=buf.st_mtime; 413 416 return TRUE; … … 425 428 PROFILE_Free( CurProfile->section ); 426 429 if (CurProfile->filename) HeapFree( SystemHeap, 0, CurProfile->filename ); 430 if (CurProfile->fullname) HeapFree(SystemHeap,0,CurProfile->fullname); 427 431 CurProfile->changed = FALSE; 428 432 CurProfile->section = NULL; 429 433 CurProfile->filename = NULL; 434 CurProfile->fullname = NULL; 430 435 CurProfile->mtime = 0; 431 436 } … … 439 444 static BOOL PROFILE_Open( LPCSTR filename ) 440 445 { 441 char buffer[MAX_PATHNAME_LEN];442 446 FILE *file = NULL; 443 447 int i,j; 444 448 struct stat buf; 445 449 PROFILE *tempProfile; 450 451 if (!filename || filename[0] == 0) return FALSE; 446 452 447 453 /* First time around */ … … 454 460 MRUProfile[i]->section=NULL; 455 461 MRUProfile[i]->filename=NULL; 462 MRUProfile[i]->fullname=NULL; 456 463 MRUProfile[i]->mtime=0; 457 464 } … … 459 466 /* Check for a match */ 460 467 461 if (!strchr( filename, '/' ) &&462 !strchr( filename, '\\' ) &&463 !strchr( filename, ':' ))464 {465 GetWindowsDirectoryA( buffer, sizeof(buffer) );466 strcat( buffer, "\\" );467 strcat( buffer, filename );468 }469 470 468 for(i=0;i<N_CACHED_PROFILES;i++) 471 469 { 472 if ( (MRUProfile[i]->filename && !strcmp( filename, MRUProfile[i]->filename)))470 if (MRUProfile[i]->filename && (!strcmp(filename,MRUProfile[i]->filename) || !strcmp(filename,MRUProfile[i]->fullname))) 473 471 { 474 472 if(i) … … 480 478 CurProfile=tempProfile; 481 479 } 482 if(!stat(CurProfile->f ilename,&buf) && CurProfile->mtime==buf.st_mtime)480 if(!stat(CurProfile->fullname,&buf) && CurProfile->mtime==buf.st_mtime) 483 481 dprintf(("Kernel32:Profile:(%s): already opened (mru=%d)\n", 484 482 filename, i )); … … 504 502 if(CurProfile->filename) PROFILE_ReleaseFile(); 505 503 506 CurProfile->filename = HEAP_strdupA( SystemHeap, 0, filename ); 507 508 file = fopen( filename, "r" ); 504 CurProfile->filename = HEAP_strdupA(SystemHeap,0,filename); 505 506 /* check for path */ 507 508 if (!strchr( filename,'/') || 509 !strchr( filename,'\\') || 510 !strchr( filename,':')) 511 { 512 char fullname[MAX_PATHNAME_LEN]; 513 514 GetWindowsDirectoryA(fullname,sizeof(fullname)); 515 strcat(fullname,"\\"); 516 strcat(fullname,filename); 517 CurProfile->fullname = HEAP_strdupA(SystemHeap,0,fullname); 518 } else CurProfile->fullname = HEAP_strdupA(SystemHeap,0,filename); 519 520 file = fopen(CurProfile->fullname,"r"); 509 521 if (file) 510 522 { 511 523 dprintf(("Kernel32:Profile:(%s): found it in %s\n", 512 filename, filename ));524 filename, CurProfile->fullname )); 513 525 514 526 CurProfile->section = PROFILE_Load( file ); 515 527 fclose( file ); 516 if(!stat(CurProfile->f ilename,&buf))528 if(!stat(CurProfile->fullname,&buf)) 517 529 CurProfile->mtime=buf.st_mtime; 518 530 } … … 520 532 { 521 533 /* Does not exist yet, we will create it in PROFILE_FlushFile */ 522 dprintf(("Kernel32:Profile:profile file %s not found\n", filename ));534 dprintf(("Kernel32:Profile:profile file %s not found\n", CurProfile->fullname )); 523 535 } 524 536 return TRUE; … … 966 978 UINT WINAPI GetProfileIntA( LPCSTR section, LPCSTR entry, INT def_val ) 967 979 { 968 return GetPrivateProfileIntA( section, entry, def_val, "win.ini");980 return GetPrivateProfileIntA( section, entry, def_val, WINININAME ); 969 981 } 970 982 … … 974 986 UINT WINAPI GetProfileIntW( LPCWSTR section, LPCWSTR entry, INT def_val ) 975 987 { 976 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini");988 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME ); 977 989 return GetPrivateProfileIntW( section, entry, def_val, wininiW ); 978 990 } … … 985 997 { 986 998 return GetPrivateProfileStringA( section, entry, def_val, 987 buffer, len, "win.ini");999 buffer, len, WINININAME ); 988 1000 } 989 1001 … … 994 1006 LPCWSTR def_val, LPWSTR buffer, UINT len ) 995 1007 { 996 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini");1008 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME ); 997 1009 return GetPrivateProfileStringW( section, entry, def_val, 998 1010 buffer, len, wininiW ); … … 1005 1017 LPCSTR string ) 1006 1018 { 1007 return WritePrivateProfileStringA( section, entry, string, "win.ini");1019 return WritePrivateProfileStringA( section, entry, string, WINININAME ); 1008 1020 } 1009 1021 … … 1014 1026 LPCWSTR string ) 1015 1027 { 1016 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini");1028 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME ); 1017 1029 return WritePrivateProfileStringW( section, entry, string, wininiW ); 1018 1030 } … … 1062 1074 1063 1075 if (!filename) 1064 filename = "win.ini";1076 filename = WINININAME; 1065 1077 1066 1078 EnterCriticalSection( &PROFILE_CritSect ); … … 1145 1157 INT WINAPI GetProfileSectionA( LPCSTR section, LPSTR buffer, DWORD len ) 1146 1158 { 1147 return GetPrivateProfileSectionA( section, buffer, len, "win.ini");1159 return GetPrivateProfileSectionA( section, buffer, len, WINININAME ); 1148 1160 } 1149 1161 … … 1153 1165 INT WINAPI GetProfileSectionW( LPCWSTR section, LPWSTR buffer, DWORD len ) 1154 1166 { 1155 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini");1167 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME ); 1156 1168 return GetPrivateProfileSectionW( section, buffer, len, wininiW ); 1157 1169 } … … 1233 1245 1234 1246 { 1235 return WritePrivateProfileSectionA( section, keys_n_values, "win.ini");1247 return WritePrivateProfileSectionA( section, keys_n_values, WINININAME); 1236 1248 } 1237 1249 … … 1241 1253 BOOL WINAPI WriteProfileSectionW( LPCWSTR section, LPCWSTR keys_n_values) 1242 1254 { 1243 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini");1255 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME); 1244 1256 1245 1257 return (WritePrivateProfileSectionW (section,keys_n_values, wininiW)); … … 1375 1387 return ret; 1376 1388 } 1389 1390 /*********************************************************************** 1391 * WriteOutProfiles (KERNEL.315) 1392 * CB: original: 16 bit function 1393 * here: necessary to save open ini files 1394 */ 1395 void WINAPI WriteOutProfiles(void) 1396 { 1397 PROFILE *lastCurProfile; 1398 INT x; 1399 1400 EnterCriticalSection(&PROFILE_CritSect); 1401 PROFILE_FlushFile(); //flash current 1402 lastCurProfile = CurProfile; 1403 for(x = 1;x < N_CACHED_PROFILES;x++) 1404 { 1405 if (MRUProfile[x]->filename) 1406 { 1407 CurProfile = MRUProfile[x]; 1408 PROFILE_FlushFile(); 1409 } 1410 } 1411 CurProfile = lastCurProfile; 1412 LeaveCriticalSection(&PROFILE_CritSect); 1413 } 1414
Note:
See TracChangeset
for help on using the changeset viewer.