FileInProjectFinder Class
class Utils::FileInProjectFinderThe FileInProjectFinder class is a helper class to find the original file in the project directory for a given file URL. More...
Header: | #include <FileInProjectFinder> |
Public Functions
Utils::FilePaths | findFile(const QUrl &fileUrl, bool *success = nullptr) const |
Detailed Description
Often files are copied in the build and deploy process. findFile() searches for an existing file in the project directory for a given file path.
For example, the following file paths should all be mapped to $PROJECTDIR/qml/app/main.qml:
- C:/app-build-desktop/qml/app/main.qml (shadow build directory)
- /Users/x/app-build-desktop/App.app/Contents/Resources/qml/App/main.qml (folder on macOS)
Member Function Documentation
Utils::FilePaths FileInProjectFinder::findFile(const QUrl &fileUrl, bool *success = nullptr) const
Returns the best match for the file URL fileUrl in the project directory.
The function first checks whether the file inside the project directory exists. If not, the leading directory in the path is stripped, and the - now shorter - path is checked for existence, and so on. Second, it tries to locate the file in the sysroot folder specified. Third, it walks the list of project files and searches for a file name match there.
If all fails, the function returns the original path from the file URL. To indicate that no match was found in the project, success is set to false.
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.