- Timestamp:
- Nov 28, 2009, 8:49:40 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/global/qlibraryinfo.cpp
r2 r357 41 41 42 42 #include "qdir.h" 43 #include "qfile.h" 43 #include "qfile.h" 44 44 #include "qconfig.h" 45 45 #include "qsettings.h" … … 58 58 # include "private/qcore_mac_p.h" 59 59 #endif 60 61 #ifdef Q_OS_OS2 62 63 #include "qt_os2.h" 64 65 static const char *qt_module_path() 66 { 67 static char path[CCHMAXPATH] = {'\0'}; 68 if (!path[0]) { 69 HMODULE hmod; 70 ULONG objNum, offset; 71 DosQueryModFromEIP(&hmod, &objNum, sizeof(path), path, &offset, 72 (ULONG)qt_module_path); 73 DosQueryModuleName(hmod, sizeof(path), path); 74 char *slash = strrchr(path, '\\'); 75 if (slash) 76 *slash = '\0'; 77 } 78 return path; 79 } 80 81 #endif // Q_OS_OS2 60 82 61 83 #include "qconfig.cpp" … … 137 159 qtconfig = pwd.filePath(QLatin1String("qt.conf")); 138 160 } 161 #ifdef Q_OS_OS2 162 if (!QFile::exists(qtconfig)) { 163 // search in the directory that contains the DLL or EXE where this 164 // code is located (e.g. QtCore.dll or app.exe if Qt is a static lib) 165 qtconfig = QString::fromLocal8Bit(qt_module_path()); 166 qtconfig = QDir::fromNativeSeparators(qtconfig) + 167 QLatin1String("/qt.conf"); 168 qtconfig = QDir::cleanPath(qtconfig); 169 170 if (!QFile::exists(qtconfig)) { 171 // search in the system-wide location 172 qtconfig = QString::fromLocal8Bit(qgetenv("ETC")); 173 if (qtconfig.isEmpty()) 174 qtconfig = QDir::rootPath(); 175 qtconfig = QDir::fromNativeSeparators(qtconfig) + 176 QLatin1String("/qt/qtsys.conf"); 177 qtconfig = QDir::cleanPath(qtconfig); 178 } 179 } 180 #endif 139 181 } 140 182 #endif … … 296 338 } 297 339 298 if (path) 340 if (path) { 299 341 ret = QString::fromLocal8Bit(path); 342 #ifdef Q_OS_OS2 343 // expand environment variables in the form $(ENVVAR) 344 int rep; 345 QRegExp reg_var(QLatin1String("\\$\\(.*\\)")); 346 reg_var.setMinimal(true); 347 while((rep = reg_var.indexIn(ret)) != -1) { 348 ret.replace(rep, reg_var.matchedLength(), 349 QString::fromLocal8Bit(qgetenv(ret.mid(rep + 2, 350 reg_var.matchedLength() - 3).toLatin1().constData()).constData())); 351 } 352 #endif 353 } 300 354 } else { 301 355 QString key; … … 431 485 // we make the prefix path absolute to the executable's directory 432 486 #ifdef QT_BUILD_QMAKE 433 return QFileInfo(qmake_libraryInfoFile()).absolutePath(); 487 QFileInfo fi(qmake_libraryInfoFile()); 488 return QDir::cleanPath(QDir(fi.absolutePath()).absoluteFilePath(ret)); 434 489 #else 490 #ifdef Q_OS_OS2 491 QSettings *config = QLibraryInfoPrivate::configuration(); 492 if (config) { 493 // if we read paths from qt[sys].conf, the Prefix is relative to 494 // the directory we load qt[sys].conf from 495 QFileInfo fi(config->fileName()); 496 return QDir::cleanPath(QDir(fi.absolutePath()).absoluteFilePath(ret)); 497 } 498 else 499 #endif 435 500 if (QCoreApplication::instance()) { 436 501 #ifdef Q_OS_MAC … … 444 509 } 445 510 #endif 446 return QDir (QCoreApplication::applicationDirPath()).absoluteFilePath(ret);511 return QDir::cleanPath(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(ret)); 447 512 } else { 448 513 return QDir::current().absoluteFilePath(ret); … … 451 516 } else { 452 517 // we make any other path absolute to the prefix directory 453 return QDir (location(PrefixPath)).absoluteFilePath(ret);518 return QDir::cleanPath(QDir(location(PrefixPath)).absoluteFilePath(ret)); 454 519 } 455 520 } 456 return ret;521 return QDir::cleanPath(ret); 457 522 } 458 523
Note:
See TracChangeset
for help on using the changeset viewer.