Changeset 20 for trunk/src/corelib/io/qfsfileengine_os2.cpp
- Timestamp:
- Jun 7, 2009, 6:38:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/io/qfsfileengine_os2.cpp
r18 r20 64 64 #include <grp.h> 65 65 66 67 66 68 QT_BEGIN_NAMESPACE 67 69 … … 374 376 bool QFSFileEngine::copy(const QString &) 375 377 { 376 // ### Add copy code for Unixhere378 // ### Add copy code for here 377 379 return false; 378 380 } … … 420 422 return true; 421 423 } 422 #if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s423 if (dirName[dirName.length() - 1] == QLatin1Char('/'))424 dirName = dirName.left(dirName.length() - 1);425 #endif426 424 return (::mkdir(QFile::encodeName(dirName), 0777) == 0); 427 425 } … … 493 491 { 494 492 QString home = QFile::decodeName(qgetenv("HOME")); 495 if (home.isNull()) 496 home = rootPath(); 493 if (home.isEmpty()) { 494 home = QFile::decodeName(qgetenv("HOMEDRIVE")) + 495 QFile::decodeName(qgetenv("HOMEPATH")); 496 if (home.isEmpty()) 497 home = rootPath(); 498 } 497 499 return home; 498 500 } … … 500 502 QString QFSFileEngine::rootPath() 501 503 { 502 return QString::fromLatin1("/"); 504 ULONG bootDrive = 0; 505 DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PVOID)&bootDrive, 506 sizeof(bootDrive)); 507 QString root = QChar((char)(bootDrive + 'A' - 1)); 508 root += ":/"; 509 return root; 503 510 } 504 511 505 512 QString QFSFileEngine::tempPath() 506 513 { 507 QString temp = QFile::decodeName(qgetenv("TMPDIR")); 508 if (temp.isEmpty()) 509 temp = QString::fromLatin1("/tmp/"); 514 QString temp = QFile::decodeName(qgetenv("TEMP")); 515 if (temp.isEmpty()) { 516 temp = QFile::decodeName(qgetenv("TMP")); 517 if (temp.isEmpty()) { 518 temp = QFile::decodeName(qgetenv("TMPDIR")); 519 if (temp.isEmpty()) 520 temp = rootPath() + "tmp"; 521 } 522 } 510 523 return temp; 511 524 } … … 514 527 { 515 528 QFileInfoList ret; 516 ret.append(rootPath()); 529 530 ULONG driveBits, dummy; 531 DosQueryCurrentDisk( &dummy, &driveBits ); 532 driveBits &= 0x3ffffff; 533 534 char driveName[4]; 535 qstrcpy( driveName, "A:/" ); 536 537 while( driveBits ) { 538 if ( driveBits & 1 ) 539 ret.append(QString::fromLatin1(driveName).toUpper()); 540 driveName[0]++; 541 driveBits = driveBits >> 1; 542 } 543 517 544 return ret; 518 545 } … … 546 573 return is_link; 547 574 } 548 549 #if !defined(QWS) && defined(Q_OS_MAC)550 static bool _q_isMacHidden(const QString &path)551 {552 OSErr err = noErr;553 554 FSRef fsRef;555 556 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)557 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {558 err = FSPathMakeRefWithOptions(reinterpret_cast<const UInt8 *>(QFile::encodeName(QDir::cleanPath(path)).constData()),559 kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0);560 } else561 #endif562 {563 QFileInfo fi(path);564 FSRef parentRef;565 err = FSPathMakeRef(reinterpret_cast<const UInt8 *>(fi.absoluteDir().absolutePath().toUtf8().constData()),566 &parentRef, 0);567 if (err == noErr) {568 QString fileName = fi.fileName();569 err = FSMakeFSRefUnicode(&parentRef, fileName.length(),570 reinterpret_cast<const UniChar *>(fileName.unicode()),571 kTextEncodingUnknown, &fsRef);572 }573 }574 if (err != noErr)575 return false;576 577 FSCatalogInfo catInfo;578 err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL);579 if (err != noErr)580 return false;581 582 FileInfo * const fileInfo = reinterpret_cast<FileInfo*>(&catInfo.finderInfo);583 bool result = (fileInfo->finderFlags & kIsInvisible);584 return result;585 }586 #endif587 575 588 576 /*! … … 630 618 } 631 619 if (type & TypesMask) { 632 #if !defined(QWS) && defined(Q_OS_MAC)633 bool foundAlias = false;634 {635 FSRef fref;636 if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(),637 &fref, NULL) == noErr) {638 Boolean isAlias, isFolder;639 if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr && isAlias) {640 foundAlias = true;641 ret |= LinkType;642 }643 }644 }645 if (!foundAlias)646 #endif647 620 { 648 621 if ((type & LinkType) && d->isSymlink()) … … 652 625 else if (exists && (d->st.st_mode & S_IFMT) == S_IFDIR) 653 626 ret |= DirectoryType; 654 #if !defined(QWS) && defined(Q_OS_MAC)655 if((ret & DirectoryType) && (type & BundleType)) {656 QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath),657 kCFURLPOSIXPathStyle, true);658 UInt32 type, creator;659 if(CFBundleGetPackageInfoInDirectory(url, &type, &creator))660 ret |= BundleType;661 }662 #endif663 627 } 664 628 } … … 667 631 if (exists) 668 632 ret |= ExistsFlag; 669 if (fileName(BaseName)[0] == QLatin1Char('.') 670 #if !defined(QWS) && defined(Q_OS_MAC) 671 || _q_isMacHidden(d->filePath) 672 #endif 673 ) 633 if (fileName(BaseName)[0] == QLatin1Char('.')) 674 634 ret |= HiddenFlag; 675 635 if (d->filePath == QLatin1String("/")) … … 683 643 Q_D(const QFSFileEngine); 684 644 if (file == BundleName) { 685 #if !defined(QWS) && defined(Q_OS_MAC)686 QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath),687 kCFURLPOSIXPathStyle, true);688 if(CFDictionaryRef dict = CFBundleCopyInfoDictionaryForURL(url)) {689 if(CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) {690 if(CFGetTypeID(name) == CFStringGetTypeID())691 return QCFString::toQString((CFStringRef)name);692 }693 }694 #endif695 645 return QString(); 696 646 } else if (file == BaseName) { … … 783 733 ret += QFile::decodeName(QByteArray(s)); 784 734 #if defined(__GLIBC__) && !defined(PATH_MAX) 785 735 ::free(s); 786 736 #endif 787 737 … … 800 750 } 801 751 } 802 #if !defined(QWS) && defined(Q_OS_MAC)803 {804 FSRef fref;805 if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(), &fref, 0) == noErr) {806 Boolean isAlias, isFolder;807 if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) {808 AliasHandle alias;809 if (FSNewAlias(0, &fref, &alias) == noErr && alias) {810 CFStringRef cfstr;811 if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr)812 return QCFString::toQString(cfstr);813 }814 }815 }816 }817 #endif818 752 return QString(); 819 753 } … … 824 758 { 825 759 Q_D(const QFSFileEngine); 826 int len = d->filePath.length();827 if (len == 0)828 return true;829 return d->filePath[0] != QLatin1Char('/');760 761 762 763 830 764 } 831 765 … … 845 779 QString QFSFileEngine::owner(FileOwner own) const 846 780 { 847 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)781 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 848 782 int size_max = sysconf(_SC_GETPW_R_SIZE_MAX); 849 783 if (size_max == -1) … … 854 788 if (own == OwnerUser) { 855 789 struct passwd *pw = 0; 856 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)790 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 857 791 struct passwd entry; 858 792 getpwuid_r(ownerId(own), &entry, buf.data(), buf.size(), &pw); … … 864 798 } else if (own == OwnerGroup) { 865 799 struct group *gr = 0; 866 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)800 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) 867 801 size_max = sysconf(_SC_GETGR_R_SIZE_MAX); 868 802 if (size_max == -1)
Note:
See TracChangeset
for help on using the changeset viewer.