Changeset 475 for trunk


Ignore:
Timestamp:
Mar 14, 2011, 9:40:39 PM (10 years ago)
Author:
Silvan Scherrer
Message:

normalize path, so save as works as designed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/gui/lucide.cpp

    r460 r475  
    720720{
    721721    bool saved = false;
     722    int buflen = 0;
    722723
    723724    char dirbuf[ CCHMAXPATH ];
     
    728729    PrfQueryProfileString( HINI_USERPROFILE, appName, prfLvd, "",
    729730                           dirbuf, sizeof( dirbuf ) );
     731    // it may be possible that the trailing \ is missing, so add it
     732    buflen = strlen(dirbuf);
     733    if ((dirbuf[buflen -1] != '\\') && (dirbuf[buflen -1] != '/'))
     734    {
     735       strcat(dirbuf, "\\");
     736    }
     737
    730738    char fil[ _MAX_FNAME ] = "";
    731739    char ext[ _MAX_EXT ] = "";
     
    751759            doSave = ( response == MBID_YES );
    752760        }
     761
    753762        if ( doSave )
    754763        {
    755764            // @todo poppler has troubles saving to the same file name
    756765            // (some locking issues) so forbid it for now
    757             if ( ( saved = false, stricmp( docFullName, fd->szFullFile ) == 0 ) ||
     766
     767           // we need to normalise the path
     768           strcpy(dirbuf, docFullName);
     769           for(buflen = 0; buflen < strlen(dirbuf); ++buflen)
     770           {
     771               if (dirbuf[buflen] == '/')
     772               {
     773                   dirbuf[buflen] = '\\';
     774               }
     775           }
     776
     777            if ( ( saved = false, stricmp( dirbuf, fd->szFullFile ) == 0 ) ||
    758778                 !( saved = doc->saveAs( ev, fd->szFullFile ) ) )
    759779            {
Note: See TracChangeset for help on using the changeset viewer.