forked from qt-creator/qt-creator
Utils: Introduce FilePath::normalizePathName()
... as wrapper around FileUtils::normalizePathName, and use it in some places. Change-Id: I42792e1f175b8119c8db930eae80a9f822ac70fa Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -822,6 +822,14 @@ FilePath FilePath::absoluteFilePath(const FilePath &tail) const
|
||||
return tail;
|
||||
}
|
||||
|
||||
FilePath FilePath::normalizePathName() const
|
||||
{
|
||||
FilePath result = *this;
|
||||
if (!needsDevice()) // FIXME: Assumes no remote Windows and Mac for now.
|
||||
result.m_data = FileUtils::normalizePathName(result.m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Constructs a FilePath from \a filename
|
||||
/// \a filename is not checked for validity.
|
||||
FilePath FilePath::fromString(const QString &filepath)
|
||||
|
@@ -120,6 +120,10 @@ public:
|
||||
FilePath absoluteFilePath() const;
|
||||
FilePath absoluteFilePath(const FilePath &tail) const;
|
||||
|
||||
// makes sure that capitalization of directories is canonical
|
||||
// on Windows and macOS. This is rarely needed.
|
||||
FilePath normalizePathName() const;
|
||||
|
||||
bool operator==(const FilePath &other) const;
|
||||
bool operator!=(const FilePath &other) const;
|
||||
bool operator<(const FilePath &other) const;
|
||||
|
@@ -913,8 +913,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, AllowTerminal allowTerm
|
||||
|
||||
m_runParameters.inferior = runnable();
|
||||
// Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...)
|
||||
m_runParameters.inferior.workingDirectory =
|
||||
FilePath::fromString(FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory.toString()));
|
||||
m_runParameters.inferior.workingDirectory = m_runParameters.inferior.workingDirectory.normalizePathName();
|
||||
setUseTerminal(allowTerminal == DoAllowTerminal && m_runParameters.useTerminal);
|
||||
|
||||
const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH");
|
||||
|
@@ -255,7 +255,7 @@ void UnstartedAppWatcherDialog::startStopTimer(bool start)
|
||||
|
||||
void UnstartedAppWatcherDialog::findProcess()
|
||||
{
|
||||
const QString &appName = Utils::FileUtils::normalizePathName(m_pathChooser->filePath().toString());
|
||||
const QString &appName = m_pathChooser->filePath().normalizePathName().toString();
|
||||
DeviceProcessItem fallback;
|
||||
foreach (const DeviceProcessItem &p, DeviceProcessList::localProcesses()) {
|
||||
if (Utils::FileUtils::normalizePathName(p.exe) == appName) {
|
||||
|
@@ -373,9 +373,9 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice::
|
||||
|
||||
if (m_isLocal) {
|
||||
// Work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch' ...)
|
||||
const QString fixedPath = FileUtils::normalizePathName(runnable.workingDirectory.toString());
|
||||
const FilePath fixedPath = runnable.workingDirectory.normalizePathName();
|
||||
m_guiProcess.setWorkingDirectory(fixedPath);
|
||||
m_consoleProcess.setWorkingDirectory(FilePath::fromString(fixedPath));
|
||||
m_consoleProcess.setWorkingDirectory(fixedPath);
|
||||
|
||||
Environment env = runnable.environment;
|
||||
if (m_runAsRoot)
|
||||
|
@@ -148,10 +148,8 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
QmlBuildSystem::QmlBuildSystem(Target *target)
|
||||
: BuildSystem(target)
|
||||
{
|
||||
const QString normalized
|
||||
= Utils::FileUtils::normalizePathName(target->project()
|
||||
->projectFilePath().toFileInfo().canonicalFilePath());
|
||||
m_canonicalProjectDir = Utils::FilePath::fromString(normalized).parentDir();
|
||||
m_canonicalProjectDir =
|
||||
target->project()->projectFilePath().canonicalPath().normalizePathName().parentDir();
|
||||
|
||||
connect(target->project(), &Project::projectFileIsDirty,
|
||||
this, &QmlBuildSystem::refreshProjectFile);
|
||||
|
@@ -449,7 +449,7 @@ void ExamplesListModel::parseTutorials(QXmlStreamReader *reader, const QString &
|
||||
static QString resourcePath()
|
||||
{
|
||||
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
|
||||
return Utils::FileUtils::normalizePathName(Core::ICore::resourcePath().toString());
|
||||
return Core::ICore::resourcePath().normalizePathName().toString();
|
||||
}
|
||||
|
||||
void ExamplesListModel::updateExamples()
|
||||
|
@@ -752,7 +752,7 @@ void MemcheckToolPrivate::heobAction()
|
||||
}
|
||||
|
||||
FilePath executable = sr.command.executable();
|
||||
const QString workingDirectory = Utils::FileUtils::normalizePathName(sr.workingDirectory.toString());
|
||||
const QString workingDirectory = sr.workingDirectory.normalizePathName().toString();
|
||||
const QString commandLineArguments = sr.command.arguments();
|
||||
const QStringList envStrings = sr.environment.toStringList();
|
||||
|
||||
|
Reference in New Issue
Block a user