MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getRelativePath

Method getRelativePath

src/Mod/Material/App/Library.cpp:183–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183QString Library::getRelativePath(const QString& path) const
184{
185 QString filePath;
186 QString clean = QDir::cleanPath(path);
187 QString prefix = QStringLiteral("/") + getName();
188 if (clean.startsWith(prefix)) {
189 // Remove the library name from the path
190 filePath = clean.right(clean.length() - prefix.length());
191 }
192 else {
193 filePath = clean;
194 }
195
196 prefix = getDirectoryPath();
197 if (filePath.startsWith(prefix, caseSensitivity())) {
198 // Remove the library root from the path
199 filePath = filePath.right(filePath.length() - prefix.length());
200 }
201
202 // Remove any leading '/'
203 if (filePath.startsWith(QStringLiteral("/"))) {
204 filePath.remove(0, 1);
205 }
206
207 return filePath;
208}
209
210QString Library::getLibraryPath(const QString& path, const QString& filename) const
211{

Callers

nothing calls this directly

Calls 5

startsWithMethod · 0.80
rightMethod · 0.80
getNameFunction · 0.70
lengthMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected