diff -rU 10 qt-x11-free-3.3.6/src/tools/qdir_unix.cpp qt-x11-free-3.3.6-fix/src/tools/qdir_unix.cpp --- qt-x11-free-3.3.6/src/tools/qdir_unix.cpp 2006-03-08 17:47:38.000000000 +0100 +++ qt-x11-free-3.3.6-fix/src/tools/qdir_unix.cpp 2006-04-02 19:00:30.000000000 +0200 @@ -64,32 +64,47 @@ d = QFile::decodeName(getenv("HOME")); slashify( d ); if ( d.isNull() ) d = rootDirPath(); return d; } QString QDir::canonicalPath() const { QString r; +#if defined(__GLIBC__) && !defined(PATH_MAX) + char *cur = get_current_dir_name(); + if ( cur ) { + char *tmp = canonicalize_file_name( QFile::encodeName( dPath ).data() ); + if ( tmp ) { + r = QFile::decodeName( tmp ); + free( tmp ); + } + slashify( r ); + // always make sure we go back to the current dir + ::chdir( cur ); + free( cur ); + } +#else char cur[PATH_MAX+1]; if ( ::getcwd( cur, PATH_MAX ) ) { char tmp[PATH_MAX+1]; // need the cast for old solaris versions of realpath that doesn't take // a const char*. if( ::realpath( (char*)QFile::encodeName( dPath ).data(), tmp ) ) r = QFile::decodeName( tmp ); slashify( r ); // always make sure we go back to the current dir ::chdir( cur ); } +#endif /* __GLIBC__ && !PATH_MAX */ return r; } bool QDir::mkdir( const QString &dirName, bool acceptAbsPath ) const { #if defined(Q_OS_MACX) // Mac X doesn't support trailing /'s QString name = dirName; if (dirName[dirName.length() - 1] == "/") name = dirName.left( dirName.length() - 1 ); int status = @@ -137,23 +152,31 @@ r = ::chdir( QFile::encodeName(path) ); return r >= 0; } QString QDir::currentDirPath() { QString result; struct stat st; if ( ::stat( ".", &st ) == 0 ) { +#if defined(__GLIBC__) && !defined(PATH_MAX) + char *currentName = get_current_dir_name(); + if ( currentName ) { + result = QFile::decodeName(currentName); + free( currentName ); + } +#else char currentName[PATH_MAX+1]; if ( ::getcwd( currentName, PATH_MAX ) ) result = QFile::decodeName(currentName); +#endif /* __GLIBC__ && !PATH_MAX */ #if defined(QT_DEBUG) if ( result.isNull() ) qWarning( "QDir::currentDirPath: getcwd() failed" ); #endif } else { #if defined(QT_DEBUG) qWarning( "QDir::currentDirPath: stat(\".\") failed" ); #endif } slashify( result ); diff -rU 10 qt-x11-free-3.3.6/src/tools/qfileinfo_unix.cpp qt-x11-free-3.3.6-fix/src/tools/qfileinfo_unix.cpp --- qt-x11-free-3.3.6/src/tools/qfileinfo_unix.cpp 2006-03-08 17:47:38.000000000 +0100 +++ qt-x11-free-3.3.6-fix/src/tools/qfileinfo_unix.cpp 2006-04-02 19:52:12.000000000 +0200 @@ -38,20 +38,23 @@ #include "qplatformdefs.h" #include "qfileinfo.h" #include "qfiledefs_p.h" #include "qdatetime.h" #include "qdir.h" #include #if !defined(QWS) && defined(Q_OS_MAC) # include #endif +#if defined(Q_OS_UNIX) && !defined(Q_OS_OS2EMX) && defined(__GLIBC__) && !defined(PATH_MAX) +# include +#endif void QFileInfo::slashify( QString& ) { return; } void QFileInfo::makeAbs( QString & ) { return; @@ -117,30 +120,55 @@ This name may not represent an existing file; it is only a string. QFileInfo::exists() returns TRUE if the symlink points to an existing file. \sa exists(), isSymLink(), isDir(), isFile() */ QString QFileInfo::readLink() const { + if ( !isSymLink() ) + return QString(); #if defined(Q_OS_UNIX) && !defined(Q_OS_OS2EMX) +#if defined(__GLIBC__) && !defined(PATH_MAX) +#define PATH_CHUNK_SIZE 100 + int size = PATH_CHUNK_SIZE; + char *s = NULL; + + while (1) + { + s = (char *) realloc (s, size); + if (s == NULL) + return QString(); + int len = readlink ( QFile::encodeName(fn).data(), s, size ); + if ( len < 0 ) { + free( s ); + return QString(); + } + if ( len < size ) { + s[len] = '\0'; + QString str = QFile::decodeName(s); + free(s); + return str; + } + size *= 2; + } +#else char s[PATH_MAX+1]; - if ( !isSymLink() ) - return QString(); int len = readlink( QFile::encodeName(fn).data(), s, PATH_MAX ); if ( len >= 0 ) { s[len] = '\0'; return QFile::decodeName(s); } -#endif +#endif /* __GLIBC__ && !PATH_MAX */ +#endif /* Q_OS_UNIX && !Q_OS_OS2EMX */ #if !defined(QWS) && defined(Q_OS_MAC) { FSRef fref; if(FSPathMakeRef((const UInt8 *)QFile::encodeName(fn).data(), &fref, NULL) == noErr) { Boolean isAlias, isFolder; if(FSResolveAliasFile(&fref, TRUE, &isFolder, &isAlias) == noErr && isAlias) { AliasHandle alias; if(FSNewAlias(0, &fref, &alias) == noErr && alias) { CFStringRef cfstr; if(FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) {