Utils: Map local path path in FilePath::onDevice(), too

To cover cases like Windows -> Docker/Linux, where these parts are not
an exact 1:1 mapping.

Change-Id: Iecc26e06771fb190644988950271ff7990962b6b
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2021-10-25 18:16:27 +02:00
parent 712caf10dc
commit c82e3cf6a8

View File

@@ -1182,10 +1182,16 @@ QString FilePath::calcRelativePath(const QString &absolutePath, const QString &a
*/
FilePath FilePath::onDevice(const FilePath &deviceTemplate) const
{
if (!deviceTemplate.needsDevice())
return mapToGlobalPath();
const bool sameDevice = m_scheme == deviceTemplate.m_scheme && m_host == deviceTemplate.m_host;
// TODO: converting paths between different non local devices is still unsupported
QTC_CHECK(!needsDevice() || sameDevice);
FilePath res;
res.m_data = m_data;
res.m_host = deviceTemplate.m_host;
res.m_scheme = deviceTemplate.m_scheme;
res.m_host = deviceTemplate.m_host;
res.m_data = m_data;
res.m_data = res.mapToDevicePath();
return res;
}