Utils::FileInProjectFinder Class
class Utils::FileInProjectFinderFileInProjectFinder クラスは、指定されたファイル URL に対応するプロジェクトディレクトリ内の元のファイルを検索するためのヘルパークラスです。詳細...
| Header: | #include <FileInProjectFinder> |
パブリック関数
| Utils::FilePaths | findFile(const QUrl &fileUrl, bool *success = nullptr) const |
詳細な説明
多くの場合、ファイルはビルドおよびデプロイの過程でコピーされます。findFile() は、指定されたファイルパスに対応する既存のファイルをプロジェクトディレクトリ内で検索します。
たとえば、以下のファイルパスはすべて $PROJECTDIR/qml/app/main.qml にマッピングされる必要があります:
- C:/app-build-desktop/qml/app/main.qml(シャドウビルドディレクトリ)
- /Users/x/app-build-desktop/App.app/Contents/Resources/qml/App/main.qml (macOS上のフォルダ)
メンバ関数のドキュメント
Utils::FilePaths FileInProjectFinder::findFile(const QUrl &fileUrl, bool *success = nullptr) const
プロジェクトディレクトリ内のファイル URLfileUrl に最も一致するものを返します。
この関数はまず、プロジェクトディレクトリ内にそのファイルが存在するかどうかを確認します。存在しない場合、パスから先頭のディレクトリを削除し、短縮されたパスについて存在確認を行い、これを繰り返します。次に、指定された sysroot フォルダ内でファイルの検索を試みます。 次に、プロジェクトファイルの一覧を順に調べ、ファイル名が一致するものを検索します。
これらすべてが失敗した場合、関数はファイルURLから取得した元のパスを返します。プロジェクト内で一致するファイルが見つからなかったことを示すため、success は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.