Ignore:
Timestamp:
Aug 17, 1999, 6:35:30 PM (26 years ago)
Author:
phaller
Message:

Fix: removed ODINCRT remains

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:12 phaller Exp $ */
     1/* $Id: profile.cpp,v 1.9 1999-08-17 16:35:10 phaller Exp $ */
    22
    33/*
     
    1010 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
    1111 * Copyright 1998 Patrick Haller
     12 * Copyright 1999 Christoph Bratschi
    1213 */
    1314
     
    6364    BOOL             changed;
    6465    PROFILESECTION  *section;
    65     char            *filename;
     66    char            *filename; //first open name
     67    char            *fullname; //name with path
    6668    time_t           mtime;
    6769} PROFILE;
     
    7981
    8082#define PROFILE_MAX_LINE_LEN   1024
     83#define WINININAME "WIN.INI"
    8184
    8285/* Wine profile name in $HOME directory; must begin with slash */
     
    9194#define WINE_INI_GLOBAL ETCDIR "/wine.conf"
    9295
    93 static LPCWSTR wininiW = NULL;
     96static LPCWSTR wininiW = NULL; //CB: never freed
    9497
    9598static CRITICAL_SECTION PROFILE_CritSect;
     
    398401
    399402    // try to open file
    400     file = fopen(CurProfile->filename, "w");
     403    file = fopen(CurProfile->fullname, "w");
    401404    if (!file)
    402405    {
    403         dprintf(("Kernel32:Profile:could not save profile file %s\n", CurProfile->filename));
     406        dprintf(("Kernel32:Profile:could not save profile file %s\n", CurProfile->fullname));
    404407        return FALSE;
    405408    }
    406409
    407     dprintf(("Kernel32:Profile:Saving %s\n", CurProfile->filename ));
     410    dprintf(("Kernel32:Profile:Saving %s\n", CurProfile->fullname ));
    408411    PROFILE_Save( file, CurProfile->section );
    409412    fclose( file );
    410413    CurProfile->changed = FALSE;
    411     if(!stat(CurProfile->filename,&buf))
     414    if(!stat(CurProfile->fullname,&buf))
    412415       CurProfile->mtime=buf.st_mtime;
    413416    return TRUE;
     
    425428    PROFILE_Free( CurProfile->section );
    426429    if (CurProfile->filename) HeapFree( SystemHeap, 0, CurProfile->filename );
     430    if (CurProfile->fullname) HeapFree(SystemHeap,0,CurProfile->fullname);
    427431    CurProfile->changed   = FALSE;
    428432    CurProfile->section   = NULL;
    429433    CurProfile->filename  = NULL;
     434    CurProfile->fullname  = NULL;
    430435    CurProfile->mtime     = 0;
    431436}
     
    439444static BOOL PROFILE_Open( LPCSTR filename )
    440445{
    441     char buffer[MAX_PATHNAME_LEN];
    442446    FILE *file = NULL;
    443447    int i,j;
    444448    struct stat buf;
    445449    PROFILE *tempProfile;
     450
     451    if (!filename || filename[0] == 0) return FALSE;
    446452
    447453    /* First time around */
     
    454460          MRUProfile[i]->section=NULL;
    455461          MRUProfile[i]->filename=NULL;
     462          MRUProfile[i]->fullname=NULL;
    456463          MRUProfile[i]->mtime=0;
    457464         }
     
    459466    /* Check for a match */
    460467
    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 
    470468    for(i=0;i<N_CACHED_PROFILES;i++)
    471469      {
    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)))
    473471         {
    474472          if(i)
     
    480478             CurProfile=tempProfile;
    481479            }
    482           if(!stat(CurProfile->filename,&buf) && CurProfile->mtime==buf.st_mtime)
     480          if(!stat(CurProfile->fullname,&buf) && CurProfile->mtime==buf.st_mtime)
    483481             dprintf(("Kernel32:Profile:(%s): already opened (mru=%d)\n",
    484482                              filename, i ));
     
    504502    if(CurProfile->filename) PROFILE_ReleaseFile();
    505503
    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");
    509521    if (file)
    510522    {
    511523      dprintf(("Kernel32:Profile:(%s): found it in %s\n",
    512                filename, filename ));
     524               filename, CurProfile->fullname ));
    513525
    514526        CurProfile->section = PROFILE_Load( file );
    515527        fclose( file );
    516         if(!stat(CurProfile->filename,&buf))
     528        if(!stat(CurProfile->fullname,&buf))
    517529           CurProfile->mtime=buf.st_mtime;
    518530    }
     
    520532    {
    521533        /* 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 ));
    523535    }
    524536    return TRUE;
     
    966978UINT WINAPI GetProfileIntA( LPCSTR section, LPCSTR entry, INT def_val )
    967979{
    968     return GetPrivateProfileIntA( section, entry, def_val, "win.ini" );
     980    return GetPrivateProfileIntA( section, entry, def_val, WINININAME );
    969981}
    970982
     
    974986UINT WINAPI GetProfileIntW( LPCWSTR section, LPCWSTR entry, INT def_val )
    975987{
    976     if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini" );
     988    if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME );
    977989    return GetPrivateProfileIntW( section, entry, def_val, wininiW );
    978990}
     
    985997{
    986998    return GetPrivateProfileStringA( section, entry, def_val,
    987                  buffer, len, "win.ini" );
     999                 buffer, len, WINININAME );
    9881000}
    9891001
     
    9941006               LPCWSTR def_val, LPWSTR buffer, UINT len )
    9951007{
    996     if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini" );
     1008    if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME );
    9971009    return GetPrivateProfileStringW( section, entry, def_val,
    9981010                 buffer, len, wininiW );
     
    10051017             LPCSTR string )
    10061018{
    1007     return WritePrivateProfileStringA( section, entry, string, "win.ini" );
     1019    return WritePrivateProfileStringA( section, entry, string, WINININAME );
    10081020}
    10091021
     
    10141026                                     LPCWSTR string )
    10151027{
    1016     if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini" );
     1028    if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME );
    10171029    return WritePrivateProfileStringW( section, entry, string, wininiW );
    10181030}
     
    10621074
    10631075    if (!filename)
    1064    filename = "win.ini";
     1076   filename = WINININAME;
    10651077
    10661078    EnterCriticalSection( &PROFILE_CritSect );
     
    11451157INT WINAPI GetProfileSectionA( LPCSTR section, LPSTR buffer, DWORD len )
    11461158{
    1147     return GetPrivateProfileSectionA( section, buffer, len, "win.ini" );
     1159    return GetPrivateProfileSectionA( section, buffer, len, WINININAME );
    11481160}
    11491161
     
    11531165INT WINAPI GetProfileSectionW( LPCWSTR section, LPWSTR buffer, DWORD len )
    11541166{
    1155     if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini" );
     1167    if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME );
    11561168    return GetPrivateProfileSectionW( section, buffer, len, wininiW );
    11571169}
     
    12331245
    12341246{
    1235     return WritePrivateProfileSectionA( section, keys_n_values, "win.ini");
     1247    return WritePrivateProfileSectionA( section, keys_n_values, WINININAME);
    12361248}
    12371249
     
    12411253BOOL WINAPI WriteProfileSectionW( LPCWSTR section, LPCWSTR keys_n_values)
    12421254{
    1243    if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini");
     1255   if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, WINININAME);
    12441256
    12451257   return (WritePrivateProfileSectionW (section,keys_n_values, wininiW));
     
    13751387    return ret;
    13761388}
     1389
     1390/***********************************************************************
     1391 *           WriteOutProfiles   (KERNEL.315)
     1392 * CB: original: 16 bit function
     1393 *     here: necessary to save open ini files
     1394 */
     1395void 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.