Changeset 365
- Timestamp:
- Nov 30, 2009, 11:51:23 PM (16 years ago)
- Location:
- trunk/src/corelib/io
- Files:
-
- 2 edited
-
qdir.cpp (modified) (2 diffs)
-
qfsfileengine_os2.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/io/qdir.cpp
r363 r365 732 732 { 733 733 Q_D(const QDir); 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 734 788 if (isAbsolutePath(fileName)) 735 789 return fileName; … … 753 807 } 754 808 return ret; 809 810 755 811 } 756 812 -
trunk/src/corelib/io/qfsfileengine_os2.cpp
r363 r365 650 650 static bool isRelativePath(const QString &path) 651 651 { 652 return !(path.startsWith(QLatin1Char('/')) 653 || (path.length() >= 2 654 && ((path.at(0).isLetter() && path.at(1) == QLatin1Char(':')) 655 || (path.at(0) == QLatin1Char('/') && path.at(1) == QLatin1Char('/'))))); // drive, e.g. a: 652 // On OS/2, paths like "A:bbb.txt" and "\ccc.dat" are not absolute (because 653 // they may lead to different locations depending on where we are). However, 654 // fixing this function will break an unfixable amount of invalid code in Qt 655 // and qmake (just search for isRelativePath in there) so that we have to 656 // live with it... See also QDir::absoluteFilePath() and 657 // isNotReallyAbsolutePath() below. 658 659 return !(path.startsWith(QLatin1Char('/')) || // "\ccc.dat" or "\\server\share..." 660 (path.length() >= 2 && path.at(0).isLetter() && // "A:bbb..." or "A:\bbb..." 661 path.at(1) == QLatin1Char(':'))); 662 } 663 664 static bool isNotReallyAbsolutePath(const QString &path) 665 { 666 // see isRelativePath(). Intended to detect a false absolute case when 667 // isRelativePath() returns true 668 669 QChar ch0, ch1, ch2; 670 if (path.length()) ch0 = path.at(0); 671 if (path.length() > 1) ch1 = path.at(1); 672 if (path.length() > 2) ch2 = path.at(2); 673 return ((ch0 == QLatin1Char('/') && ch1 != QLatin1Char('/')) || // "\ccc.dat" 674 (ch0.isLetter() && ch1 == QLatin1Char(':') && // "A:bbb.txt" (but not A:) 675 !ch2.isNull() && ch2 != QLatin1Char('/'))); 656 676 } 657 677 … … 687 707 QString ret; 688 708 689 if (!isRelativePath()) { 690 if (d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':') 691 && d->filePath.at(2) != QLatin1Char('/') || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt 692 d->filePath.startsWith(QLatin1Char('/')) // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt 693 ) { 709 if (!::isRelativePath(d->filePath)) { 710 if (::isNotReallyAbsolutePath(d->filePath)) { 694 711 char buf[PATH_MAX+1]; 695 712 strcpy(buf, QFile::encodeName(d->filePath).constData()); … … 749 766 QString ret; 750 767 if (!::isRelativePath(target)) { 751 if (target.size() > 2 && target.at(1) == QLatin1Char(':') 752 && target.at(2) != QLatin1Char('/') || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt 753 target.startsWith(QLatin1Char('/')) // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt 754 ) { 768 if (::isNotReallyAbsolutePath(target)) { 755 769 char buf[PATH_MAX+1]; 756 770 strcpy(buf, QFile::encodeName(target).constData());
Note:
See TracChangeset
for help on using the changeset viewer.
