* @return whether a given URL can possibly point to a file * * KTextEditor (plugins) might look up or open a document by a local-file URL with an empty file name. * DocumentController asserts that a URL passed to it has a nonempty file name or is not a local file. This * function helps slots that implement KTextEditor API to properly fail instead of triggering the assertion failures. * * @pr
| 76 | * @pre @p !url.isRelative() because a relative URL is never a local file, and so must be resolved before the check |
| 77 | */ |
| 78 | [[nodiscard]] bool canPointToFile(const QUrl& url) |
| 79 | { |
| 80 | Q_ASSERT(!url.isEmpty()); |
| 81 | Q_ASSERT(!url.isRelative()); |
| 82 | return !url.fileName().isEmpty() || !url.isLocalFile(); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * If a given URL is a local file, return a version of the URL |
no test coverage detected