* @brief path to the near ancestor that exists * */
| 1191 | * |
| 1192 | */ |
| 1193 | QString nearestExistentAncestor(const QString& path) |
| 1194 | { |
| 1195 | if (QFileInfo::exists(path)) |
| 1196 | return path; |
| 1197 | |
| 1198 | QDir dir(path); |
| 1199 | if (!dir.makeAbsolute()) |
| 1200 | return {}; |
| 1201 | do { |
| 1202 | dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral("..")))); |
| 1203 | } while (!dir.exists() && !dir.isRoot()); |
| 1204 | |
| 1205 | return dir.exists() ? dir.path() : QString(); |
| 1206 | } |
| 1207 | |
| 1208 | /** |
| 1209 | * @brief colect information about the filesystem under a file |