Index: /trunk/src/corelib/io/qfsfileengine_iterator_os2.cpp
===================================================================
--- /trunk/src/corelib/io/qfsfileengine_iterator_os2.cpp	(revision 19)
+++ /trunk/src/corelib/io/qfsfileengine_iterator_os2.cpp	(revision 20)
@@ -57,5 +57,5 @@
     inline QFSFileEngineIteratorPlatformSpecificData()
         : dir(0), dirEntry(0), done(false)
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
           , mt_file(0)
 #endif
@@ -66,5 +66,5 @@
     bool done;
 
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
     // for readdir_r
     dirent *mt_file;
@@ -79,5 +79,5 @@
         return;
 
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
     if (::readdir_r(platform->dir, platform->mt_file, &platform->dirEntry) != 0)
         platform->done = true;
@@ -90,5 +90,5 @@
         platform->dir = 0;
         platform->done = true;
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
         delete [] platform->mt_file;
         platform->mt_file = 0;
@@ -106,5 +106,5 @@
     if (platform->dir) {
         ::closedir(platform->dir);
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
         delete [] platform->mt_file;
         platform->mt_file = 0;
@@ -127,5 +127,5 @@
                 maxPathName = FILENAME_MAX;
             maxPathName += sizeof(dirent) + 1;
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
             if (that->platform->mt_file)
                 delete [] that->platform->mt_file;
Index: /trunk/src/corelib/io/qfsfileengine_os2.cpp
===================================================================
--- /trunk/src/corelib/io/qfsfileengine_os2.cpp	(revision 19)
+++ /trunk/src/corelib/io/qfsfileengine_os2.cpp	(revision 20)
@@ -64,4 +64,6 @@
 #include <grp.h>
 
+#include "qt_os2.h"
+
 QT_BEGIN_NAMESPACE
 
@@ -374,5 +376,5 @@
 bool QFSFileEngine::copy(const QString &)
 {
-    // ### Add copy code for Unix here
+    // ### Add copy code for OS/2 here
     return false;
 }
@@ -420,8 +422,4 @@
         return true;
     }
-#if defined(Q_OS_DARWIN)  // Mac X doesn't support trailing /'s
-    if (dirName[dirName.length() - 1] == QLatin1Char('/'))
-        dirName = dirName.left(dirName.length() - 1);
-#endif
     return (::mkdir(QFile::encodeName(dirName), 0777) == 0);
 }
@@ -493,6 +491,10 @@
 {
     QString home = QFile::decodeName(qgetenv("HOME"));
-    if (home.isNull())
-        home = rootPath();
+    if (home.isEmpty()) {
+        home = QFile::decodeName(qgetenv("HOMEDRIVE")) +
+               QFile::decodeName(qgetenv("HOMEPATH"));
+        if (home.isEmpty())
+            home = rootPath();
+    }
     return home;
 }
@@ -500,12 +502,23 @@
 QString QFSFileEngine::rootPath()
 {
-    return QString::fromLatin1("/");
+    ULONG bootDrive = 0;
+    DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PVOID)&bootDrive,
+                    sizeof(bootDrive));
+    QString root = QChar((char)(bootDrive + 'A' - 1));
+    root += ":/";
+    return root;
 }
 
 QString QFSFileEngine::tempPath()
 {
-    QString temp = QFile::decodeName(qgetenv("TMPDIR"));
-    if (temp.isEmpty())
-        temp = QString::fromLatin1("/tmp/");
+    QString temp = QFile::decodeName(qgetenv("TEMP"));
+    if (temp.isEmpty()) {
+        temp = QFile::decodeName(qgetenv("TMP"));
+        if (temp.isEmpty()) {
+            temp = QFile::decodeName(qgetenv("TMPDIR"));
+            if (temp.isEmpty())
+                temp = rootPath() + "tmp";
+        }
+    }
     return temp;
 }
@@ -514,5 +527,19 @@
 {
     QFileInfoList ret;
-    ret.append(rootPath());
+
+	ULONG driveBits, dummy;
+	DosQueryCurrentDisk( &dummy, &driveBits );
+	driveBits &= 0x3ffffff;
+
+	char driveName[4];
+	qstrcpy( driveName, "A:/" );
+
+	while( driveBits ) {
+	    if ( driveBits & 1 )
+		ret.append(QString::fromLatin1(driveName).toUpper());
+	    driveName[0]++;
+	    driveBits = driveBits >> 1;
+	}
+
     return ret;
 }
@@ -546,43 +573,4 @@
     return is_link;
 }
-
-#if !defined(QWS) && defined(Q_OS_MAC)
-static bool _q_isMacHidden(const QString &path)
-{
-    OSErr err = noErr;
-
-    FSRef fsRef;
-
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
-    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
-        err = FSPathMakeRefWithOptions(reinterpret_cast<const UInt8 *>(QFile::encodeName(QDir::cleanPath(path)).constData()),
-                                        kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0);
-    } else
-#endif
-    {
-        QFileInfo fi(path);
-        FSRef parentRef;
-        err = FSPathMakeRef(reinterpret_cast<const UInt8 *>(fi.absoluteDir().absolutePath().toUtf8().constData()),
-                            &parentRef, 0);
-        if (err == noErr) {
-            QString fileName = fi.fileName();
-            err = FSMakeFSRefUnicode(&parentRef, fileName.length(),
-                                     reinterpret_cast<const UniChar *>(fileName.unicode()),
-                                     kTextEncodingUnknown, &fsRef);
-        }
-    }
-    if (err != noErr)
-        return false;
-
-    FSCatalogInfo catInfo;
-    err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL);
-    if (err != noErr)
-        return false;
-
-    FileInfo * const fileInfo = reinterpret_cast<FileInfo*>(&catInfo.finderInfo);
-    bool result = (fileInfo->finderFlags & kIsInvisible);
-    return result;
-}
-#endif
 
 /*!
@@ -630,19 +618,4 @@
     }
     if (type & TypesMask) {
-#if !defined(QWS) && defined(Q_OS_MAC)
-        bool foundAlias = false;
-        {
-            FSRef fref;
-            if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(),
-                             &fref, NULL) == noErr) {
-                Boolean isAlias, isFolder;
-                if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr && isAlias) {
-                    foundAlias = true;
-                    ret |= LinkType;
-                }
-            }
-        }
-        if (!foundAlias)
-#endif
         {
             if ((type & LinkType) && d->isSymlink())
@@ -652,13 +625,4 @@
             else if (exists && (d->st.st_mode & S_IFMT) == S_IFDIR)
                 ret |= DirectoryType;
-#if !defined(QWS) && defined(Q_OS_MAC)
-            if((ret & DirectoryType) && (type & BundleType)) {
-                QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath),
-                                                                      kCFURLPOSIXPathStyle, true);
-                UInt32 type, creator;
-                if(CFBundleGetPackageInfoInDirectory(url, &type, &creator))
-                    ret |= BundleType;
-            }
-#endif
         }
     }
@@ -667,9 +631,5 @@
         if (exists)
             ret |= ExistsFlag;
-        if (fileName(BaseName)[0] == QLatin1Char('.')
-#if !defined(QWS) && defined(Q_OS_MAC)
-            || _q_isMacHidden(d->filePath)
-#endif
-        )
+        if (fileName(BaseName)[0] == QLatin1Char('.'))
             ret |= HiddenFlag;
         if (d->filePath == QLatin1String("/"))
@@ -683,14 +643,4 @@
     Q_D(const QFSFileEngine);
     if (file == BundleName) {
-#if !defined(QWS) && defined(Q_OS_MAC)
-        QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath),
-                                                              kCFURLPOSIXPathStyle, true);
-        if(CFDictionaryRef dict = CFBundleCopyInfoDictionaryForURL(url)) {
-            if(CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) {
-                if(CFGetTypeID(name) == CFStringGetTypeID())
-                    return QCFString::toQString((CFStringRef)name);
-            }
-        }
-#endif
         return QString();
     } else if (file == BaseName) {
@@ -783,5 +733,5 @@
                 ret += QFile::decodeName(QByteArray(s));
 #if defined(__GLIBC__) && !defined(PATH_MAX)
-		::free(s);
+                ::free(s);
 #endif
 
@@ -800,20 +750,4 @@
             }
         }
-#if !defined(QWS) && defined(Q_OS_MAC)
-        {
-            FSRef fref;
-            if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(), &fref, 0) == 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)
-                            return QCFString::toQString(cfstr);
-                    }
-                }
-            }
-        }
-#endif
         return QString();
     }
@@ -824,8 +758,8 @@
 {
     Q_D(const QFSFileEngine);
-    int len = d->filePath.length();
-    if (len == 0)
-        return true;
-    return d->filePath[0] != QLatin1Char('/');
+    return !(d->filePath.startsWith(QLatin1Char('/'))
+        || (d->filePath.length() >= 2
+        && ((d->filePath.at(0).isLetter() && d->filePath.at(1) == QLatin1Char(':'))
+        || (d->filePath.at(0) == QLatin1Char('/') && d->filePath.at(1) == QLatin1Char('/')))));                // drive, e.g. a:
 }
 
@@ -845,5 +779,5 @@
 QString QFSFileEngine::owner(FileOwner own) const
 {
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
     int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
     if (size_max == -1)
@@ -854,5 +788,5 @@
     if (own == OwnerUser) {
         struct passwd *pw = 0;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
         struct passwd entry;
         getpwuid_r(ownerId(own), &entry, buf.data(), buf.size(), &pw);
@@ -864,5 +798,5 @@
     } else if (own == OwnerGroup) {
         struct group *gr = 0;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
         size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
         if (size_max == -1)
