Changeset 187


Ignore:
Timestamp:
Nov 9, 2008, 10:47:20 PM (17 years ago)
Author:
dmik
Message:

Tools: QDir::canonicalPath(): Use realpath()/DosQueryPathInfo() instead of non-threadsafe chdir() approach.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tools/qdir_pm.cpp

    r123 r187  
    5252#include "qt_os2.h"
    5353
     54#include <stdlib.h>
     55
    5456void QDir::slashify( QString& n )
    5557{
     
    9294    QString r;
    9395
    94 #if defined(Q_CC_GNU)
    95     char drv = 0;
    96     if ( dPath[0].isLetter() && dPath[1] == ':' ) {
    97         drv = _getdrive();
    98         _chdrive( dPath[0].upper().latin1() );
    99     }
     96    char tmp[PATH_MAX];
     97
     98#if defined (__INNOTEK_LIBC__)
     99    if ( realpath( QFile::encodeName( dPath ), tmp ) != NULL )
     100        r = QFile::decodeName( tmp );
    100101#else
    101     int drv = 0;
    102     if ( dPath[0].isLetter() && dPath[1] == ':' ) {
    103         drv = _getdrive();
    104         _chdrive( dPath[0].upper().latin1() - 'A' + 1 );
    105     }
     102    if ( DosQueryPathInfo( QFile::encodeName( dPath ),
     103                           FIL_QUERYFULLNAME, tmp, sizeof(tmp) ) == 0 )
     104        r = QFile::decodeName( tmp );
    106105#endif
    107 
    108     char cur[PATH_MAX];
    109     QT_GETCWD( cur, PATH_MAX );
    110     if ( QT_CHDIR( QFile::encodeName( dPath ) ) == 0 ) {
    111         char tmp[PATH_MAX];
    112         if ( QT_GETCWD( tmp, PATH_MAX ) != 0 )
    113             r = QFile::decodeName( tmp );
    114     }
    115     QT_CHDIR( cur );
    116 
    117     if ( drv )
    118         _chdrive( drv );
    119106
    120107    slashify( r );
Note: See TracChangeset for help on using the changeset viewer.