* @brief path to the near ancestor that exists * */
| 1200 | * |
| 1201 | */ |
| 1202 | QString nearestExistentAncestor(const QString& path) |
| 1203 | { |
| 1204 | if (QFileInfo::exists(path)) |
| 1205 | return path; |
| 1206 | |
| 1207 | QDir dir(path); |
| 1208 | if (!dir.makeAbsolute()) |
| 1209 | return {}; |
| 1210 | do { |
| 1211 | dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral("..")))); |
| 1212 | } while (!dir.exists() && !dir.isRoot()); |
| 1213 | |
| 1214 | return dir.exists() ? dir.path() : QString(); |
| 1215 | } |
| 1216 | |
| 1217 | /** |
| 1218 | * @brief colect information about the filesystem under a file |