diff options
Diffstat (limited to 'tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp')
-rw-r--r-- | tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp b/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp index 921b9f9..3be62bf 100644 --- a/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp +++ b/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp @@ -48,6 +48,9 @@ #if !defined(TQWS) && defined(TQ_OS_MAC) # include <tqt_mac.h> #endif +#if defined(Q_OS_HURD) +# include <stdlib.h> +#endif void TQFileInfo::slashify( TQString& ) { @@ -127,16 +130,43 @@ bool TQFileInfo::isSymLink() const TQString TQFileInfo::readLink() const { + if ( !isSymLink() ) + return TQString(); #if defined(TQ_OS_UNIX) && !defined(TQ_OS_OS2EMX) +#if defined(__GLIBC__) && !defined(PATH_MAX) + int size = 256; + char *s = NULL, *s2; + + while (1) + { + s2 = (char *) realloc (s, size); + if (s2 == NULL) { + free( s ); + return TQString(); + } + s = s2; + int len = readlink ( TQFile::encodeName(fn).data(), s, size ); + if ( len < 0 ) { + free( s ); + return TQString(); + } + if ( len < size ) { + s[len] = '\0'; + TQString str = TQFile::decodeName(s); + free(s); + return str; + } + size *= 2; + } +#else char s[PATH_MAX+1]; - if ( !isSymLink() ) - return TQString(); int len = readlink( TQFile::encodeName(fn).data(), s, PATH_MAX ); if ( len >= 0 ) { s[len] = '\0'; return TQFile::decodeName(s); } -#endif +#endif /* __GLIBC__ && !PATH_MAX */ +#endif /* Q_OS_UNIX && !Q_OS_OS2EMX */ #if !defined(TQWS) && defined(TQ_OS_MAC) { FSRef fref; |