-rw-r--r-- | qmake/tools/qdir.cpp | 94 |
1 files changed, 71 insertions, 23 deletions
diff --git a/qmake/tools/qdir.cpp b/qmake/tools/qdir.cpp index 418ea49..5714878 100644 --- a/qmake/tools/qdir.cpp +++ b/qmake/tools/qdir.cpp | |||
@@ -7,3 +7,3 @@ | |||
7 | ** | 7 | ** |
8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
@@ -45,5 +45,9 @@ | |||
45 | #include "qstringlist.h" | 45 | #include "qstringlist.h" |
46 | #include <stdlib.h> | 46 | #include <limits.h> |
47 | #include <ctype.h> | ||
48 | 47 | ||
48 | #if defined(Q_FS_FAT) && !defined(Q_OS_UNIX) | ||
49 | const bool CaseSensitiveFS = FALSE; | ||
50 | #else | ||
51 | const bool CaseSensitiveFS = TRUE; | ||
52 | #endif | ||
49 | 53 | ||
@@ -52,2 +56,3 @@ | |||
52 | \class QDir | 56 | \class QDir |
57 | \reentrant | ||
53 | \brief The QDir class provides access to directory structures and their contents in a platform-independent way. | 58 | \brief The QDir class provides access to directory structures and their contents in a platform-independent way. |
@@ -232,2 +237,10 @@ QDir::QDir( const QDir &d ) | |||
232 | 237 | ||
238 | /*! | ||
239 | Refreshes the directory information. | ||
240 | */ | ||
241 | void QDir::refresh() const | ||
242 | { | ||
243 | QDir* that = (QDir*) this; | ||
244 | that->dirty = TRUE; | ||
245 | } | ||
233 | 246 | ||
@@ -384,6 +397,32 @@ QString QDir::absFilePath( const QString &fileName, | |||
384 | QString tmp = absPath(); | 397 | QString tmp = absPath(); |
385 | if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName && | 398 | #ifdef Q_OS_WIN32 |
386 | fileName[0] != '/') ) | 399 | if ( fileName[0].isLetter() && fileName[1] == ':' ) { |
387 | tmp += '/'; | 400 | int drv = fileName.upper()[0].latin1() - 'A' + 1; |
388 | tmp += fileName; | 401 | if ( _getdrive() != drv ) { |
402 | if ( qt_winunicode ) { | ||
403 | TCHAR buf[PATH_MAX]; | ||
404 | ::_tgetdcwd( drv, buf, PATH_MAX ); | ||
405 | tmp.setUnicodeCodes( (ushort*)buf, ::_tcslen(buf) ); | ||
406 | } else { | ||
407 | char buf[PATH_MAX]; | ||
408 | ::_getdcwd( drv, buf, PATH_MAX ); | ||
409 | tmp = buf; | ||
410 | } | ||
411 | if ( !tmp.endsWith("\\") ) | ||
412 | tmp += "\\"; | ||
413 | tmp += fileName.right( fileName.length() - 2 ); | ||
414 | int x; | ||
415 | for ( x = 0; x < (int) tmp.length(); x++ ) { | ||
416 | if ( tmp[x] == '\\' ) | ||
417 | tmp[x] = '/'; | ||
418 | } | ||
419 | } | ||
420 | } else | ||
421 | #endif | ||
422 | { | ||
423 | if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName && | ||
424 | fileName[0] != '/') ) | ||
425 | tmp += '/'; | ||
426 | tmp += fileName; | ||
427 | } | ||
389 | return tmp; | 428 | return tmp; |
@@ -936,3 +975,4 @@ QDir &QDir::operator=( const QString &path ) | |||
936 | QDir d2( "bin" ); | 975 | QDir d2( "bin" ); |
937 | if ( d1 != d2 ) qDebug( "They differ\n" ); // This is printed | 976 | if ( d1 != d2 ) |
977 | qDebug( "They differ" ); | ||
938 | \endcode | 978 | \endcode |
@@ -951,3 +991,4 @@ QDir &QDir::operator=( const QString &path ) | |||
951 | d2.convertToAbs(); | 991 | d2.convertToAbs(); |
952 | if ( d1 == d2 ) qDebug( "They're the same\n" ); // This is printed | 992 | if ( d1 == d2 ) |
993 | qDebug( "They're the same" ); | ||
953 | \endcode | 994 | \endcode |
@@ -1089,6 +1130,7 @@ QDir QDir::root() | |||
1089 | 1130 | ||
1090 | QStringList qt_makeFilterList( const QString &filter ) | 1131 | QValueList<QRegExp> qt_makeFilterList( const QString &filter ) |
1091 | { | 1132 | { |
1133 | QValueList<QRegExp> regExps; | ||
1092 | if ( filter.isEmpty() ) | 1134 | if ( filter.isEmpty() ) |
1093 | return QStringList(); | 1135 | return regExps; |
1094 | 1136 | ||
@@ -1101,11 +1143,22 @@ QStringList qt_makeFilterList( const QString &filter ) | |||
1101 | QStringList::Iterator it = list.begin(); | 1143 | QStringList::Iterator it = list.begin(); |
1102 | QStringList list2; | 1144 | while ( it != list.end() ) { |
1145 | regExps << QRegExp( (*it).stripWhiteSpace(), CaseSensitiveFS, TRUE ); | ||
1146 | ++it; | ||
1147 | } | ||
1148 | return regExps; | ||
1149 | } | ||
1103 | 1150 | ||
1104 | for ( ; it != list.end(); ++it ) { | 1151 | bool qt_matchFilterList( const QValueList<QRegExp>& filters, |
1105 | QString s = *it; | 1152 | const QString &fileName ) |
1106 | list2 << s.stripWhiteSpace(); | 1153 | { |
1154 | QValueList<QRegExp>::ConstIterator rit = filters.begin(); | ||
1155 | while ( rit != filters.end() ) { | ||
1156 | if ( (*rit).exactMatch(fileName) ) | ||
1157 | return TRUE; | ||
1158 | ++rit; | ||
1107 | } | 1159 | } |
1108 | return list2; | 1160 | return FALSE; |
1109 | } | 1161 | } |
1110 | 1162 | ||
1163 | |||
1111 | /*! | 1164 | /*! |
@@ -1125,7 +1178,3 @@ bool QDir::match( const QStringList &filters, const QString &fileName ) | |||
1125 | while ( sit != filters.end() ) { | 1178 | while ( sit != filters.end() ) { |
1126 | #if defined(Q_FS_FAT) && !defined(Q_OS_UNIX) | 1179 | QRegExp rx( *sit, CaseSensitiveFS, TRUE ); |
1127 | QRegExp rx( *sit, FALSE, TRUE ); // The FAT FS is not case sensitive.. | ||
1128 | #else | ||
1129 | QRegExp rx( *sit, TRUE, TRUE ); // ..while others are. | ||
1130 | #endif | ||
1131 | if ( rx.exactMatch(fileName) ) | 1180 | if ( rx.exactMatch(fileName) ) |
@@ -1149,4 +1198,3 @@ bool QDir::match( const QString &filter, const QString &fileName ) | |||
1149 | { | 1198 | { |
1150 | QStringList lst = qt_makeFilterList( filter ); | 1199 | return qt_matchFilterList( qt_makeFilterList(filter), fileName ); |
1151 | return match( lst, fileName ); | ||
1152 | } | 1200 | } |