diff options
Diffstat (limited to 'experimental/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp')
-rw-r--r-- | experimental/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/experimental/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp b/experimental/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp index 921b9f9b0..3be62bfb6 100644 --- a/experimental/tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp +++ b/experimental/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; |