MCPcopy Create free account
hub / github.com/KDE/kdevelop / preserveWindowsDriveLetter

Function preserveWindowsDriveLetter

kdevplatform/util/tests/test_path.cpp:174–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172/// Invoke @p op on URL @p base, but preserve drive letter if @p op removes it
173template<typename Func>
174QUrl preserveWindowsDriveLetter(const QUrl& base, Func op)
175{
176#ifndef Q_OS_WIN
177 return op(base);
178#else
179 // only apply to local files
180 if (!base.isLocalFile()) {
181 return op(base);
182 }
183
184 // save drive letter
185 const QString windowsDriveLetter = base.toLocalFile().mid(0, 2);
186 QUrl url = op(base);
187 // restore drive letter
188 if (url.toLocalFile().startsWith('/')) {
189 url = QUrl::fromLocalFile(windowsDriveLetter + url.toLocalFile());
190 }
191 return url;
192#endif
193}
194
195QUrl resolvedUrl(const QUrl& base, const QUrl& relative)
196{

Callers 2

resolvedUrlFunction · 0.85
comparableUpUrlFunction · 0.85

Calls 3

isLocalFileMethod · 0.80
midMethod · 0.80
toLocalFileMethod · 0.80

Tested by

no test coverage detected