src/libraries.cpp

changeset 12
fe67489523b5
parent 8
44679e468ba9
child 22
6da867fa5429
equal deleted inserted replaced
11:771168ee2c76 12:fe67489523b5
42 /** 42 /**
43 * @brief Searches the libraries for the specified file name. 43 * @brief Searches the libraries for the specified file name.
44 * @param fileName File to search for 44 * @param fileName File to search for
45 * @return Full path to the file, or empty string if not found. 45 * @return Full path to the file, or empty string if not found.
46 */ 46 */
47 QFileInfo LibraryManager::findFile(QString fileName) const 47 QString LibraryManager::findFile(QString fileName) const
48 { 48 {
49 QFileInfo path; 49 QString path;
50 fileName.replace("\\", "/"); 50 fileName.replace("\\", "/");
51 bool found = false; 51 bool found = false;
52 for (const Library& library : this->libraries) 52 for (const Library& library : this->libraries)
53 { 53 {
54 path = library.path.absoluteFilePath(fileName); 54 for (const QString& subdirectory : {"parts", "p"})
55 if (path.exists() && path.isFile()) 55 {
56 { 56 QDir directory = library.path;
57 found = true; 57 directory.cd(subdirectory);
58 QFileInfo fileInfo = directory.absoluteFilePath(fileName);
59 if (fileInfo.exists() && fileInfo.isFile())
60 {
61 path = fileInfo.absoluteFilePath();
62 found = true;
63 break;
64 }
65 }
66 if (found)
67 {
58 break; 68 break;
59 } 69 }
60 } 70 }
61 if (not found)
62 path = {};
63 return path; 71 return path;
64 } 72 }
65 73
66 /** 74 /**
67 * @brief Adds a new library to the end of the libraries list. 75 * @brief Adds a new library to the end of the libraries list.

mercurial