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 Mac OS X)
Member Function Documentation
Utils::FilePaths FileInProjectFinder::findFile(const QUrl &fileUrl, bool *success = nullptr) const
Returns the best match for the given file URL 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, we walk the list of project files, and search for a file name match there. If all fails, it returns the original path from the file URL.