summaryrefslogtreecommitdiff
path: root/qmake/tools/qdir_unix.cpp
Unidiff
Diffstat (limited to 'qmake/tools/qdir_unix.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qdir_unix.cpp54
1 files changed, 30 insertions, 24 deletions
diff --git a/qmake/tools/qdir_unix.cpp b/qmake/tools/qdir_unix.cpp
index 57fe3c5..6a7adda 100644
--- a/qmake/tools/qdir_unix.cpp
+++ b/qmake/tools/qdir_unix.cpp
@@ -5,7 +5,7 @@
5** 5**
6** Created : 950628 6** Created : 950628
7** 7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
@@ -51,6 +51,7 @@
51 51
52#include <stdlib.h> 52#include <stdlib.h>
53#include <limits.h> 53#include <limits.h>
54#include <errno.h>
54 55
55 56
56void QDir::slashify( QString& ) 57void QDir::slashify( QString& )
@@ -70,17 +71,16 @@ QString QDir::homeDirPath()
70QString QDir::canonicalPath() const 71QString QDir::canonicalPath() const
71{ 72{
72 QString r; 73 QString r;
73
74 char cur[PATH_MAX+1]; 74 char cur[PATH_MAX+1];
75 if ( ::getcwd( cur, PATH_MAX ) ) 75 if ( ::getcwd( cur, PATH_MAX ) ) {
76 if ( ::chdir(QFile::encodeName(dPath)) >= 0 ) { 76 char tmp[PATH_MAX+1];
77 char tmp[PATH_MAX+1]; 77 if( ::realpath( QFile::encodeName( dPath ), tmp ) )
78 if ( ::getcwd( tmp, PATH_MAX ) ) 78 r = QFile::decodeName( tmp );
79 r = QFile::decodeName(tmp); 79 slashify( r );
80 ::chdir( cur ); 80
81 } 81 // always make sure we go back to the current dir
82 82 ::chdir( cur );
83 slashify( r ); 83 }
84 return r; 84 return r;
85} 85}
86 86
@@ -90,12 +90,13 @@ bool QDir::mkdir( const QString &dirName, bool acceptAbsPath ) const
90 QString name = dirName; 90 QString name = dirName;
91 if (dirName[dirName.length() - 1] == "/") 91 if (dirName[dirName.length() - 1] == "/")
92 name = dirName.left( dirName.length() - 1 ); 92 name = dirName.left( dirName.length() - 1 );
93 return ::mkdir( QFile::encodeName(filePath(name,acceptAbsPath)), 0777 ) 93 int status =
94 == 0; 94 ::mkdir( QFile::encodeName(filePath(name,acceptAbsPath)), 0777 );
95#else 95#else
96 return ::mkdir( QFile::encodeName(filePath(dirName,acceptAbsPath)), 0777 ) 96 int status =
97 == 0; 97 ::mkdir( QFile::encodeName(filePath(dirName,acceptAbsPath)), 0777 );
98#endif 98#endif
99 return status == 0;
99} 100}
100 101
101bool QDir::rmdir( const QString &dirName, bool acceptAbsPath ) const 102bool QDir::rmdir( const QString &dirName, bool acceptAbsPath ) const
@@ -186,7 +187,7 @@ bool QDir::readDirEntries( const QString &nameFilter,
186 fiList->clear(); 187 fiList->clear();
187 } 188 }
188 189
189 QStringList filters = qt_makeFilterList( nameFilter ); 190 QValueList<QRegExp> filters = qt_makeFilterList( nameFilter );
190 191
191 bool doDirs = (filterSpec & Dirs)!= 0; 192 bool doDirs = (filterSpec & Dirs)!= 0;
192 bool doFiles = (filterSpec & Files)!= 0; 193 bool doFiles = (filterSpec & Files)!= 0;
@@ -197,11 +198,6 @@ bool QDir::readDirEntries( const QString &nameFilter,
197 bool doHidden = (filterSpec & Hidden)!= 0; 198 bool doHidden = (filterSpec & Hidden)!= 0;
198 bool doSystem = (filterSpec & System) != 0; 199 bool doSystem = (filterSpec & System) != 0;
199 200
200#if defined(Q_OS_OS2EMX)
201 //QRegExp wc( nameFilter, FALSE, TRUE );// wild card, case insensitive
202#else
203 //QRegExp wc( nameFilter, TRUE, TRUE );// wild card, case sensitive
204#endif
205 QFileInfo fi; 201 QFileInfo fi;
206 DIR *dir; 202 DIR *dir;
207 dirent *file; 203 dirent *file;
@@ -210,10 +206,19 @@ bool QDir::readDirEntries( const QString &nameFilter,
210 if ( !dir ) 206 if ( !dir )
211 return FALSE; // cannot read the directory 207 return FALSE; // cannot read the directory
212 208
213 while ( (file = readdir(dir)) ) { 209#if defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
210 union {
211 struct dirent mt_file;
212 char b[sizeof(struct dirent) + MAXNAMLEN + 1];
213 } u;
214 while ( readdir_r(dir, &u.mt_file, &file ) == 0 && file )
215#else
216 while ( (file = readdir(dir)) )
217#endif // QT_THREAD_SUPPORT && _POSIX_THREAD_SAFE_FUNCTIONS
218 {
214 QString fn = QFile::decodeName(file->d_name); 219 QString fn = QFile::decodeName(file->d_name);
215 fi.setFile( *this, fn ); 220 fi.setFile( *this, fn );
216 if ( !match( filters, fn ) && !(allDirs && fi.isDir()) ) 221 if ( !qt_matchFilterList(filters, fn) && !(allDirs && fi.isDir()) )
217 continue; 222 continue;
218 if ( (doDirs && fi.isDir()) || (doFiles && fi.isFile()) || 223 if ( (doDirs && fi.isDir()) || (doFiles && fi.isFile()) ||
219 (doSystem && (!fi.isFile() && !fi.isDir())) ) { 224 (doSystem && (!fi.isFile() && !fi.isDir())) ) {
@@ -276,7 +281,8 @@ const QFileInfoList * QDir::drives()
276 if ( !knownMemoryLeak ) { 281 if ( !knownMemoryLeak ) {
277 282
278#ifdef QT_THREAD_SUPPORT 283#ifdef QT_THREAD_SUPPORT
279 QMutexLocker locker( qt_global_mutexpool->get( &knownMemoryLeak ) ); 284 QMutexLocker locker( qt_global_mutexpool ?
285 qt_global_mutexpool->get( &knownMemoryLeak ) : 0 );
280#endif // QT_THREAD_SUPPORT 286#endif // QT_THREAD_SUPPORT
281 287
282 if ( !knownMemoryLeak ) { 288 if ( !knownMemoryLeak ) {