BsProjectLibrary.cpp 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. #include "BsProjectLibrary.h"
  2. #include "BsFileSystem.h"
  3. #include "BsException.h"
  4. #include "BsResources.h"
  5. #include "BsResourceManifest.h"
  6. #include "BsImporter.h"
  7. #include "BsProjectResourceMeta.h"
  8. #include "BsResources.h"
  9. #include "BsImporter.h"
  10. #include "BsImportOptions.h"
  11. #include "BsFileSerializer.h"
  12. #include "BsDebug.h"
  13. #include "BsProjectLibraryEntries.h"
  14. #include "BsResource.h"
  15. #include "BsEditorApplication.h"
  16. #include "BsShader.h"
  17. #include <regex>
  18. using namespace std::placeholders;
  19. namespace BansheeEngine
  20. {
  21. const Path ProjectLibrary::RESOURCES_DIR = L"Resources\\";
  22. const Path ProjectLibrary::INTERNAL_RESOURCES_DIR = PROJECT_INTERNAL_DIR + L"Resources\\";
  23. const WString ProjectLibrary::LIBRARY_ENTRIES_FILENAME = L"ProjectLibrary.asset";
  24. const WString ProjectLibrary::RESOURCE_MANIFEST_FILENAME = L"ResourceManifest.asset";
  25. ProjectLibrary::LibraryEntry::LibraryEntry()
  26. :parent(nullptr), type(LibraryEntryType::Directory)
  27. { }
  28. ProjectLibrary::LibraryEntry::LibraryEntry(const Path& path, const WString& name, DirectoryEntry* parent, LibraryEntryType type)
  29. :path(path), parent(parent), type(type), elementName(name)
  30. { }
  31. ProjectLibrary::ResourceEntry::ResourceEntry()
  32. : lastUpdateTime(0)
  33. { }
  34. ProjectLibrary::ResourceEntry::ResourceEntry(const Path& path, const WString& name, DirectoryEntry* parent)
  35. : LibraryEntry(path, name, parent, LibraryEntryType::File), lastUpdateTime(0)
  36. { }
  37. ProjectLibrary::DirectoryEntry::DirectoryEntry()
  38. { }
  39. ProjectLibrary::DirectoryEntry::DirectoryEntry(const Path& path, const WString& name, DirectoryEntry* parent)
  40. :LibraryEntry(path, name, parent, LibraryEntryType::Directory)
  41. { }
  42. ProjectLibrary::ProjectLibrary()
  43. : mRootEntry(nullptr), mIsLoaded(false)
  44. {
  45. mRootEntry = bs_new<DirectoryEntry>(mResourcesFolder, mResourcesFolder.getWTail(), nullptr);
  46. }
  47. ProjectLibrary::~ProjectLibrary()
  48. {
  49. clearEntries();
  50. }
  51. void ProjectLibrary::update()
  52. {
  53. while (!mReimportQueue.empty())
  54. {
  55. Path toReimport = *mReimportQueue.begin();
  56. LibraryEntry* entry = findEntry(toReimport);
  57. if (entry != nullptr && entry->type == LibraryEntryType::File)
  58. {
  59. ResourceEntry* resEntry = static_cast<ResourceEntry*>(entry);
  60. reimportResourceInternal(resEntry, resEntry->meta->getImportOptions(), true);
  61. queueDependantForReimport(resEntry);
  62. }
  63. mReimportQueue.erase(mReimportQueue.begin());
  64. }
  65. }
  66. void ProjectLibrary::checkForModifications(const Path& fullPath)
  67. {
  68. Vector<Path> dirtyResources;
  69. checkForModifications(fullPath, true, dirtyResources);
  70. }
  71. void ProjectLibrary::checkForModifications(const Path& fullPath, bool import, Vector<Path>& dirtyResources)
  72. {
  73. if (!mResourcesFolder.includes(fullPath))
  74. return; // Folder not part of our resources path, so no modifications
  75. if(mRootEntry == nullptr)
  76. {
  77. mRootEntry = bs_new<DirectoryEntry>(mResourcesFolder, mResourcesFolder.getWTail(), nullptr);
  78. }
  79. Path pathToSearch = fullPath;
  80. LibraryEntry* entry = findEntry(pathToSearch);
  81. if (entry == nullptr) // File could be new, try to find parent directory entry
  82. {
  83. if (FileSystem::exists(pathToSearch))
  84. {
  85. if (isMeta(pathToSearch))
  86. {
  87. Path sourceFilePath = pathToSearch;
  88. sourceFilePath.setExtension(L"");
  89. if (!FileSystem::isFile(sourceFilePath))
  90. {
  91. LOGWRN("Found a .meta file without a corresponding resource. Deleting.");
  92. FileSystem::remove(pathToSearch);
  93. }
  94. }
  95. else
  96. {
  97. Path parentDirPath = pathToSearch.getParent();
  98. entry = findEntry(parentDirPath);
  99. // Cannot find parent directory. Create the needed hierarchy.
  100. DirectoryEntry* entryParent = nullptr;
  101. DirectoryEntry* newHierarchyParent = nullptr;
  102. if (entry == nullptr)
  103. createInternalParentHierarchy(pathToSearch, &newHierarchyParent, &entryParent);
  104. else
  105. entryParent = static_cast<DirectoryEntry*>(entry);
  106. if (FileSystem::isFile(pathToSearch))
  107. {
  108. if (import)
  109. addResourceInternal(entryParent, pathToSearch);
  110. dirtyResources.push_back(pathToSearch);
  111. }
  112. else if (FileSystem::isDirectory(pathToSearch))
  113. {
  114. addDirectoryInternal(entryParent, pathToSearch);
  115. checkForModifications(pathToSearch);
  116. }
  117. }
  118. }
  119. }
  120. else if(entry->type == LibraryEntryType::File)
  121. {
  122. if(FileSystem::isFile(entry->path))
  123. {
  124. ResourceEntry* resEntry = static_cast<ResourceEntry*>(entry);
  125. if (import)
  126. {
  127. reimportResourceInternal(resEntry);
  128. queueDependantForReimport(resEntry);
  129. }
  130. if (!isUpToDate(resEntry))
  131. dirtyResources.push_back(entry->path);
  132. }
  133. else
  134. {
  135. deleteResourceInternal(static_cast<ResourceEntry*>(entry));
  136. }
  137. }
  138. else if(entry->type == LibraryEntryType::Directory) // Check folder and all subfolders for modifications
  139. {
  140. if(!FileSystem::isDirectory(entry->path))
  141. {
  142. deleteDirectoryInternal(static_cast<DirectoryEntry*>(entry));
  143. }
  144. else
  145. {
  146. Stack<DirectoryEntry*> todo;
  147. todo.push(static_cast<DirectoryEntry*>(entry));
  148. Vector<Path> childFiles;
  149. Vector<Path> childDirectories;
  150. Vector<bool> existingEntries;
  151. Vector<LibraryEntry*> toDelete;
  152. while(!todo.empty())
  153. {
  154. DirectoryEntry* currentDir = todo.top();
  155. todo.pop();
  156. existingEntries.clear();
  157. existingEntries.resize(currentDir->mChildren.size());
  158. for(UINT32 i = 0; i < (UINT32)currentDir->mChildren.size(); i++)
  159. existingEntries[i] = false;
  160. childFiles.clear();
  161. childDirectories.clear();
  162. FileSystem::getChildren(currentDir->path, childFiles, childDirectories);
  163. for(auto& filePath : childFiles)
  164. {
  165. if(isMeta(filePath))
  166. {
  167. Path sourceFilePath = filePath;
  168. sourceFilePath.setExtension(L"");
  169. if(!FileSystem::isFile(sourceFilePath))
  170. {
  171. LOGWRN("Found a .meta file without a corresponding resource. Deleting.");
  172. FileSystem::remove(filePath);
  173. }
  174. }
  175. else
  176. {
  177. ResourceEntry* existingEntry = nullptr;
  178. UINT32 idx = 0;
  179. for(auto& child : currentDir->mChildren)
  180. {
  181. if(child->type == LibraryEntryType::File && child->path == filePath)
  182. {
  183. existingEntries[idx] = true;
  184. existingEntry = static_cast<ResourceEntry*>(child);
  185. break;
  186. }
  187. idx++;
  188. }
  189. if(existingEntry != nullptr)
  190. {
  191. if (import)
  192. {
  193. reimportResourceInternal(existingEntry);
  194. queueDependantForReimport(existingEntry);
  195. }
  196. if (!isUpToDate(existingEntry))
  197. dirtyResources.push_back(existingEntry->path);
  198. }
  199. else
  200. {
  201. if (import)
  202. addResourceInternal(currentDir, filePath);
  203. dirtyResources.push_back(filePath);
  204. }
  205. }
  206. }
  207. for(auto& dirPath : childDirectories)
  208. {
  209. DirectoryEntry* existingEntry = nullptr;
  210. UINT32 idx = 0;
  211. for(auto& child : currentDir->mChildren)
  212. {
  213. if(child->type == LibraryEntryType::Directory && child->path == dirPath)
  214. {
  215. existingEntries[idx] = true;
  216. existingEntry = static_cast<DirectoryEntry*>(child);
  217. break;
  218. }
  219. idx++;
  220. }
  221. if(existingEntry == nullptr)
  222. addDirectoryInternal(currentDir, dirPath);
  223. }
  224. {
  225. for(UINT32 i = 0; i < (UINT32)existingEntries.size(); i++)
  226. {
  227. if(existingEntries[i])
  228. continue;
  229. toDelete.push_back(currentDir->mChildren[i]);
  230. }
  231. for(auto& child : toDelete)
  232. {
  233. if(child->type == LibraryEntryType::Directory)
  234. deleteDirectoryInternal(static_cast<DirectoryEntry*>(child));
  235. else if(child->type == LibraryEntryType::File)
  236. deleteResourceInternal(static_cast<ResourceEntry*>(child));
  237. }
  238. toDelete.clear();
  239. }
  240. for(auto& child : currentDir->mChildren)
  241. {
  242. if(child->type == LibraryEntryType::Directory)
  243. todo.push(static_cast<DirectoryEntry*>(child));
  244. }
  245. }
  246. }
  247. }
  248. }
  249. ProjectLibrary::ResourceEntry* ProjectLibrary::addResourceInternal(DirectoryEntry* parent, const Path& filePath,
  250. const ImportOptionsPtr& importOptions, bool forceReimport)
  251. {
  252. ResourceEntry* newResource = bs_new<ResourceEntry>(filePath, filePath.getWTail(), parent);
  253. parent->mChildren.push_back(newResource);
  254. reimportResourceInternal(newResource, importOptions, forceReimport);
  255. doOnEntryAdded(newResource);
  256. return newResource;
  257. }
  258. ProjectLibrary::DirectoryEntry* ProjectLibrary::addDirectoryInternal(DirectoryEntry* parent, const Path& dirPath)
  259. {
  260. DirectoryEntry* newEntry = bs_new<DirectoryEntry>(dirPath, dirPath.getWTail(), parent);
  261. parent->mChildren.push_back(newEntry);
  262. doOnEntryAdded(newEntry);
  263. return newEntry;
  264. }
  265. void ProjectLibrary::deleteResourceInternal(ResourceEntry* resource)
  266. {
  267. if(resource->meta != nullptr)
  268. {
  269. String uuid = resource->meta->getUUID();
  270. Path path;
  271. if (mResourceManifest->uuidToFilePath(uuid, path))
  272. {
  273. if(FileSystem::isFile(path))
  274. FileSystem::remove(path);
  275. mResourceManifest->unregisterResource(uuid);
  276. }
  277. mUUIDToPath.erase(uuid);
  278. }
  279. Path metaPath = getMetaPath(resource->path);
  280. if (FileSystem::isFile(metaPath))
  281. FileSystem::remove(metaPath);
  282. DirectoryEntry* parent = resource->parent;
  283. auto findIter = std::find_if(parent->mChildren.begin(), parent->mChildren.end(),
  284. [&] (const LibraryEntry* entry) { return entry == resource; });
  285. parent->mChildren.erase(findIter);
  286. doOnEntryRemoved(resource);
  287. bs_delete(resource);
  288. }
  289. void ProjectLibrary::deleteDirectoryInternal(DirectoryEntry* directory)
  290. {
  291. if(directory == mRootEntry)
  292. mRootEntry = nullptr;
  293. Vector<LibraryEntry*> childrenToDestroy = directory->mChildren;
  294. for(auto& child : childrenToDestroy)
  295. {
  296. if(child->type == LibraryEntryType::Directory)
  297. deleteDirectoryInternal(static_cast<DirectoryEntry*>(child));
  298. else
  299. deleteResourceInternal(static_cast<ResourceEntry*>(child));
  300. }
  301. DirectoryEntry* parent = directory->parent;
  302. if(parent != nullptr)
  303. {
  304. auto findIter = std::find_if(parent->mChildren.begin(), parent->mChildren.end(),
  305. [&] (const LibraryEntry* entry) { return entry == directory; });
  306. parent->mChildren.erase(findIter);
  307. }
  308. doOnEntryRemoved(directory);
  309. bs_delete(directory);
  310. }
  311. void ProjectLibrary::reimportResourceInternal(ResourceEntry* resource, const ImportOptionsPtr& importOptions, bool forceReimport)
  312. {
  313. Path metaPath = resource->path;
  314. metaPath.setFilename(metaPath.getWFilename() + L".meta");
  315. if(resource->meta == nullptr)
  316. {
  317. if(FileSystem::isFile(metaPath))
  318. {
  319. FileDecoder fs(metaPath);
  320. std::shared_ptr<IReflectable> loadedMeta = fs.decode();
  321. if(loadedMeta != nullptr && loadedMeta->isDerivedFrom(ProjectResourceMeta::getRTTIStatic()))
  322. {
  323. ProjectResourceMetaPtr resourceMeta = std::static_pointer_cast<ProjectResourceMeta>(loadedMeta);
  324. resource->meta = resourceMeta;
  325. mUUIDToPath[resourceMeta->getUUID()] = resource->path;
  326. }
  327. }
  328. }
  329. if (!isUpToDate(resource) || forceReimport)
  330. {
  331. // Note: If resource is native we just copy it to the internal folder. We could avoid the copy and
  332. // load the resource directly from the Resources folder but that requires complicating library code.
  333. bool isNativeResource = isNative(resource);
  334. ImportOptionsPtr curImportOptions = nullptr;
  335. if (importOptions == nullptr && !isNativeResource)
  336. {
  337. if (resource->meta != nullptr)
  338. curImportOptions = resource->meta->getImportOptions();
  339. else
  340. curImportOptions = Importer::instance().createImportOptions(resource->path);
  341. }
  342. else
  343. curImportOptions = importOptions;
  344. HResource importedResource;
  345. if (isNativeResource)
  346. importedResource = gResources().load(resource->path);
  347. if(resource->meta == nullptr)
  348. {
  349. if (!isNativeResource)
  350. importedResource = Importer::instance().import(resource->path, curImportOptions);
  351. if (importedResource != nullptr)
  352. {
  353. ResourceMetaDataPtr subMeta = importedResource->getMetaData();
  354. UINT32 typeId = importedResource->getTypeId();
  355. resource->meta = ProjectResourceMeta::create(importedResource.getUUID(), typeId, subMeta, curImportOptions);
  356. }
  357. else
  358. resource->meta = ProjectResourceMeta::create(importedResource.getUUID(), 0, nullptr, curImportOptions);
  359. FileEncoder fs(metaPath);
  360. fs.encode(resource->meta.get());
  361. mUUIDToPath[resource->meta->getUUID()] = resource->path;
  362. }
  363. else
  364. {
  365. removeDependencies(resource);
  366. if (!isNativeResource)
  367. {
  368. importedResource = HResource(resource->meta->getUUID());
  369. Importer::instance().reimport(importedResource, resource->path, curImportOptions);
  370. }
  371. }
  372. addDependencies(resource);
  373. if (importedResource != nullptr)
  374. {
  375. Path internalResourcesPath = mProjectFolder;
  376. internalResourcesPath.append(INTERNAL_RESOURCES_DIR);
  377. if (!FileSystem::isDirectory(internalResourcesPath))
  378. FileSystem::createDir(internalResourcesPath);
  379. internalResourcesPath.setFilename(toWString(importedResource.getUUID()) + L".asset");
  380. gResources().save(importedResource, internalResourcesPath, true);
  381. if (!isNativeResource)
  382. gResources().unload(importedResource);
  383. mResourceManifest->registerResource(importedResource.getUUID(), internalResourcesPath);
  384. }
  385. resource->lastUpdateTime = std::time(nullptr);
  386. }
  387. }
  388. bool ProjectLibrary::isUpToDate(ResourceEntry* resource) const
  389. {
  390. if(resource->meta == nullptr)
  391. return false;
  392. Path path;
  393. if(!mResourceManifest->uuidToFilePath(resource->meta->getUUID(), path))
  394. return false;
  395. if(!FileSystem::isFile(path))
  396. return false;
  397. std::time_t lastModifiedTime = FileSystem::getLastModifiedTime(path);
  398. return lastModifiedTime <= resource->lastUpdateTime;
  399. }
  400. Vector<ProjectLibrary::LibraryEntry*> ProjectLibrary::search(const WString& pattern)
  401. {
  402. return search(pattern, {});
  403. }
  404. Vector<ProjectLibrary::LibraryEntry*> ProjectLibrary::search(const WString& pattern, const Vector<UINT32>& typeIds)
  405. {
  406. Vector<LibraryEntry*> foundEntries;
  407. std::wregex escape(L"[.^$|()\\[\\]{}*+?\\\\]");
  408. WString replace(L"\\\\&");
  409. WString escapedPattern = std::regex_replace(pattern, escape, replace, std::regex_constants::match_default | std::regex_constants::format_sed);
  410. std::wregex wildcard(L"\\\\\\*");
  411. WString wildcardReplace(L".*");
  412. WString searchPattern = std::regex_replace(escapedPattern, wildcard, L".*");
  413. std::wregex searchRegex(searchPattern, std::regex_constants::ECMAScript | std::regex_constants::icase);
  414. Stack<DirectoryEntry*> todo;
  415. todo.push(mRootEntry);
  416. while (!todo.empty())
  417. {
  418. DirectoryEntry* dirEntry = todo.top();
  419. todo.pop();
  420. for (auto& child : dirEntry->mChildren)
  421. {
  422. if (std::regex_match(child->elementName, searchRegex))
  423. {
  424. if (typeIds.size() == 0)
  425. foundEntries.push_back(child);
  426. else
  427. {
  428. if (child->type == LibraryEntryType::File)
  429. {
  430. ResourceEntry* childResEntry = static_cast<ResourceEntry*>(child);
  431. for (auto& typeId : typeIds)
  432. {
  433. if (childResEntry->meta->getTypeID() == typeId)
  434. {
  435. foundEntries.push_back(child);
  436. break;
  437. }
  438. }
  439. }
  440. }
  441. }
  442. if (child->type == LibraryEntryType::Directory)
  443. {
  444. DirectoryEntry* childDirEntry = static_cast<DirectoryEntry*>(child);
  445. todo.push(childDirEntry);
  446. }
  447. }
  448. }
  449. std::sort(foundEntries.begin(), foundEntries.end(),
  450. [&](const LibraryEntry* a, const LibraryEntry* b)
  451. {
  452. return a->elementName.compare(b->elementName) < 0;
  453. });
  454. return foundEntries;
  455. }
  456. ProjectLibrary::LibraryEntry* ProjectLibrary::findEntry(const Path& path) const
  457. {
  458. Path fullPath = path;
  459. if (fullPath.isAbsolute())
  460. {
  461. if (!mResourcesFolder.includes(fullPath))
  462. return nullptr;
  463. }
  464. else
  465. fullPath.makeAbsolute(mResourcesFolder);
  466. Path relPath = fullPath.getRelative(mRootEntry->path);
  467. UINT32 numElems = relPath.getNumDirectories() + (relPath.isFile() ? 1 : 0);
  468. UINT32 idx = 0;
  469. LibraryEntry* current = mRootEntry;
  470. while (current != nullptr)
  471. {
  472. if (idx == numElems)
  473. return current;
  474. WString curElem;
  475. if (relPath.isFile() && idx == (numElems - 1))
  476. curElem = relPath.getWFilename();
  477. else
  478. curElem = relPath[idx];
  479. if (current->type == LibraryEntryType::Directory)
  480. {
  481. DirectoryEntry* dirEntry = static_cast<DirectoryEntry*>(current);
  482. current = nullptr;
  483. for (auto& child : dirEntry->mChildren)
  484. {
  485. if (Path::comparePathElem(curElem, child->elementName))
  486. {
  487. idx++;
  488. current = child;
  489. break;
  490. }
  491. }
  492. }
  493. else
  494. break;
  495. }
  496. return nullptr;
  497. }
  498. Path ProjectLibrary::uuidToPath(const String& uuid) const
  499. {
  500. auto iterFind = mUUIDToPath.find(uuid);
  501. if (iterFind != mUUIDToPath.end())
  502. return iterFind->second;
  503. return Path::BLANK;
  504. }
  505. void ProjectLibrary::createEntry(const HResource& resource, const Path& path)
  506. {
  507. if (resource == nullptr)
  508. return;
  509. Path assetPath = path;
  510. if (path.isAbsolute())
  511. {
  512. if (!getResourcesFolder().includes(path))
  513. return;
  514. assetPath = path.getRelative(getResourcesFolder());
  515. }
  516. LibraryEntry* existingEntry = findEntry(assetPath);
  517. if (existingEntry != nullptr)
  518. {
  519. LOGWRN("Resource already exists at the specified path : " + assetPath.toString() + ". Unable to save.");
  520. return;
  521. }
  522. resource->setName(path.getWFilename(false));
  523. Path absPath = assetPath.getAbsolute(getResourcesFolder());
  524. Resources::instance().save(resource, absPath, false);
  525. checkForModifications(absPath);
  526. }
  527. void ProjectLibrary::saveEntry(const HResource& resource)
  528. {
  529. if (resource == nullptr)
  530. return;
  531. Path filePath = uuidToPath(resource.getUUID());
  532. filePath.makeAbsolute(getResourcesFolder());
  533. Resources::instance().save(resource, filePath, true);
  534. }
  535. void ProjectLibrary::createFolderEntry(const Path& path)
  536. {
  537. Path fullPath = path;
  538. if (fullPath.isAbsolute())
  539. {
  540. if (!mResourcesFolder.includes(fullPath))
  541. return;
  542. }
  543. else
  544. fullPath.makeAbsolute(mResourcesFolder);
  545. if (FileSystem::isDirectory(fullPath))
  546. return; // Already exists
  547. FileSystem::createDir(fullPath);
  548. Path parentPath = fullPath.getParent();
  549. DirectoryEntry* newEntryParent = nullptr;
  550. LibraryEntry* newEntryParentLib = findEntry(parentPath);
  551. if (newEntryParentLib != nullptr)
  552. {
  553. assert(newEntryParentLib->type == LibraryEntryType::Directory);
  554. newEntryParent = static_cast<DirectoryEntry*>(newEntryParentLib);
  555. }
  556. DirectoryEntry* newHierarchyParent = nullptr;
  557. if (newEntryParent == nullptr) // New path parent doesn't exist, so we need to create the hierarchy
  558. createInternalParentHierarchy(fullPath, &newHierarchyParent, &newEntryParent);
  559. addDirectoryInternal(newEntryParent, fullPath);
  560. }
  561. void ProjectLibrary::moveEntry(const Path& oldPath, const Path& newPath, bool overwrite)
  562. {
  563. Path oldFullPath = oldPath;
  564. if (!oldFullPath.isAbsolute())
  565. oldFullPath.makeAbsolute(mResourcesFolder);
  566. Path newFullPath = newPath;
  567. if (!newFullPath.isAbsolute())
  568. newFullPath.makeAbsolute(mResourcesFolder);
  569. if(FileSystem::isFile(oldFullPath) || FileSystem::isDirectory(oldFullPath))
  570. FileSystem::move(oldFullPath, newFullPath, overwrite);
  571. Path oldMetaPath = getMetaPath(oldFullPath);
  572. Path newMetaPath = getMetaPath(newFullPath);
  573. LibraryEntry* oldEntry = findEntry(oldFullPath);
  574. if(oldEntry != nullptr) // Moving from the Resources folder
  575. {
  576. // Moved outside of Resources, delete entry & meta file
  577. if (!mResourcesFolder.includes(newFullPath))
  578. {
  579. if(oldEntry->type == LibraryEntryType::File)
  580. deleteResourceInternal(static_cast<ResourceEntry*>(oldEntry));
  581. else if(oldEntry->type == LibraryEntryType::Directory)
  582. deleteDirectoryInternal(static_cast<DirectoryEntry*>(oldEntry));
  583. }
  584. else // Just moving internally
  585. {
  586. doOnEntryRemoved(oldEntry);
  587. if(FileSystem::isFile(oldMetaPath))
  588. FileSystem::move(oldMetaPath, newMetaPath);
  589. DirectoryEntry* parent = oldEntry->parent;
  590. auto findIter = std::find(parent->mChildren.begin(), parent->mChildren.end(), oldEntry);
  591. if(findIter != parent->mChildren.end())
  592. parent->mChildren.erase(findIter);
  593. Path parentPath = newFullPath.getParent();
  594. DirectoryEntry* newEntryParent = nullptr;
  595. LibraryEntry* newEntryParentLib = findEntry(parentPath);
  596. if(newEntryParentLib != nullptr)
  597. {
  598. assert(newEntryParentLib->type == LibraryEntryType::Directory);
  599. newEntryParent = static_cast<DirectoryEntry*>(newEntryParentLib);
  600. }
  601. DirectoryEntry* newHierarchyParent = nullptr;
  602. if(newEntryParent == nullptr) // New path parent doesn't exist, so we need to create the hierarchy
  603. createInternalParentHierarchy(newFullPath, &newHierarchyParent, &newEntryParent);
  604. newEntryParent->mChildren.push_back(oldEntry);
  605. oldEntry->parent = newEntryParent;
  606. oldEntry->path = newFullPath;
  607. oldEntry->elementName = newFullPath.getWTail();
  608. if(oldEntry->type == LibraryEntryType::Directory) // Update child paths
  609. {
  610. Stack<LibraryEntry*> todo;
  611. todo.push(oldEntry);
  612. while(!todo.empty())
  613. {
  614. LibraryEntry* curEntry = todo.top();
  615. todo.pop();
  616. DirectoryEntry* curDirEntry = static_cast<DirectoryEntry*>(curEntry);
  617. for(auto& child : curDirEntry->mChildren)
  618. {
  619. child->path = child->parent->path;
  620. child->path.append(child->elementName);
  621. if(child->type == LibraryEntryType::Directory)
  622. todo.push(child);
  623. }
  624. }
  625. }
  626. doOnEntryAdded(oldEntry);
  627. }
  628. }
  629. else // Moving from outside of the Resources folder (likely adding a new resource)
  630. {
  631. checkForModifications(newFullPath);
  632. }
  633. }
  634. void ProjectLibrary::copyEntry(const Path& oldPath, const Path& newPath, bool overwrite)
  635. {
  636. Path oldFullPath = oldPath;
  637. if (!oldFullPath.isAbsolute())
  638. oldFullPath.makeAbsolute(mResourcesFolder);
  639. Path newFullPath = newPath;
  640. if (!newFullPath.isAbsolute())
  641. newFullPath.makeAbsolute(mResourcesFolder);
  642. if (!FileSystem::exists(oldFullPath))
  643. return;
  644. FileSystem::copy(oldFullPath, newFullPath, overwrite);
  645. // Copying a file/folder outside of the Resources folder, no special handling needed
  646. if (!mResourcesFolder.includes(newFullPath))
  647. return;
  648. Path parentPath = newFullPath.getParent();
  649. DirectoryEntry* newEntryParent = nullptr;
  650. LibraryEntry* newEntryParentLib = findEntry(parentPath);
  651. if (newEntryParentLib != nullptr)
  652. {
  653. assert(newEntryParentLib->type == LibraryEntryType::Directory);
  654. newEntryParent = static_cast<DirectoryEntry*>(newEntryParentLib);
  655. }
  656. // If the source is outside of Resources folder, just plain import the copy
  657. LibraryEntry* oldEntry = findEntry(oldFullPath);
  658. if (oldEntry == nullptr)
  659. {
  660. checkForModifications(newFullPath);
  661. return;
  662. }
  663. // Both source and destination are within Resources folder, need to preserve import options on the copies
  664. LibraryEntry* newEntry = nullptr;
  665. if (FileSystem::isFile(newFullPath))
  666. {
  667. assert(oldEntry->type == LibraryEntryType::File);
  668. ResourceEntry* oldResEntry = static_cast<ResourceEntry*>(oldEntry);
  669. newEntry = addResourceInternal(newEntryParent, newFullPath, oldResEntry->meta->getImportOptions(), true);
  670. }
  671. else
  672. {
  673. assert(oldEntry->type == LibraryEntryType::File);
  674. DirectoryEntry* oldDirEntry = static_cast<DirectoryEntry*>(oldEntry);
  675. DirectoryEntry* newDirEntry = addDirectoryInternal(newEntryParent, newFullPath);
  676. newEntry = newDirEntry;
  677. Stack<std::tuple<DirectoryEntry*, DirectoryEntry*>> todo;
  678. todo.push(std::make_tuple(oldDirEntry, newDirEntry));
  679. while (!todo.empty())
  680. {
  681. auto current = todo.top();
  682. todo.pop();
  683. DirectoryEntry* sourceDir = std::get<0>(current);
  684. DirectoryEntry* destDir = std::get<1>(current);
  685. for (auto& child : sourceDir->mChildren)
  686. {
  687. Path childDestPath = destDir->path;
  688. childDestPath.append(child->path.getWTail());
  689. if (child->type == LibraryEntryType::File)
  690. {
  691. ResourceEntry* childResEntry = static_cast<ResourceEntry*>(child);
  692. addResourceInternal(destDir, childDestPath, childResEntry->meta->getImportOptions(), true);
  693. }
  694. else // Directory
  695. {
  696. DirectoryEntry* childSourceDirEntry = static_cast<DirectoryEntry*>(child);
  697. DirectoryEntry* childDestDirEntry = addDirectoryInternal(destDir, childDestPath);
  698. todo.push(std::make_tuple(childSourceDirEntry, childSourceDirEntry));
  699. }
  700. }
  701. }
  702. }
  703. }
  704. void ProjectLibrary::deleteEntry(const Path& path)
  705. {
  706. Path fullPath = path;
  707. if (!fullPath.isAbsolute())
  708. fullPath.makeAbsolute(mResourcesFolder);
  709. if(FileSystem::exists(fullPath))
  710. FileSystem::remove(fullPath);
  711. LibraryEntry* entry = findEntry(fullPath);
  712. if(entry != nullptr)
  713. {
  714. if(entry->type == LibraryEntryType::File)
  715. deleteResourceInternal(static_cast<ResourceEntry*>(entry));
  716. else if(entry->type == LibraryEntryType::Directory)
  717. deleteDirectoryInternal(static_cast<DirectoryEntry*>(entry));
  718. }
  719. }
  720. void ProjectLibrary::reimport(const Path& path, const ImportOptionsPtr& importOptions, bool forceReimport)
  721. {
  722. LibraryEntry* entry = findEntry(path);
  723. if (entry != nullptr)
  724. {
  725. if (entry->type == LibraryEntryType::File)
  726. {
  727. ResourceEntry* resEntry = static_cast<ResourceEntry*>(entry);
  728. reimportResourceInternal(resEntry, importOptions, forceReimport);
  729. queueDependantForReimport(resEntry);
  730. }
  731. }
  732. }
  733. void ProjectLibrary::setIncludeInBuild(const Path& path, bool include)
  734. {
  735. LibraryEntry* entry = findEntry(path);
  736. if (entry == nullptr || entry->type == LibraryEntryType::Directory)
  737. return;
  738. ResourceEntry* resEntry = static_cast<ResourceEntry*>(entry);
  739. if (resEntry->meta == nullptr)
  740. return;
  741. resEntry->meta->setIncludeInBuild(include);
  742. Path metaPath = resEntry->path;
  743. metaPath.setFilename(metaPath.getWFilename() + L".meta");
  744. FileEncoder fs(metaPath);
  745. fs.encode(resEntry->meta.get());
  746. }
  747. Vector<ProjectLibrary::ResourceEntry*> ProjectLibrary::getResourcesForBuild() const
  748. {
  749. Vector<ResourceEntry*> output;
  750. Stack<DirectoryEntry*> todo;
  751. todo.push(mRootEntry);
  752. while (!todo.empty())
  753. {
  754. DirectoryEntry* directory = todo.top();
  755. todo.pop();
  756. for (auto& child : directory->mChildren)
  757. {
  758. if (child->type == LibraryEntryType::File)
  759. {
  760. ResourceEntry* resEntry = static_cast<ResourceEntry*>(child);
  761. if (resEntry->meta != nullptr && resEntry->meta->getIncludeInBuild())
  762. output.push_back(resEntry);
  763. }
  764. else if (child->type == LibraryEntryType::Directory)
  765. {
  766. todo.push(static_cast<DirectoryEntry*>(child));
  767. }
  768. }
  769. }
  770. return output;
  771. }
  772. HResource ProjectLibrary::load(const Path& path)
  773. {
  774. LibraryEntry* entry = findEntry(path);
  775. if (entry == nullptr || entry->type == LibraryEntryType::Directory)
  776. return HResource();
  777. ResourceEntry* resEntry = static_cast<ResourceEntry*>(entry);
  778. String resUUID = resEntry->meta->getUUID();
  779. return gResources().loadFromUUID(resUUID);
  780. }
  781. void ProjectLibrary::createInternalParentHierarchy(const Path& fullPath, DirectoryEntry** newHierarchyRoot, DirectoryEntry** newHierarchyLeaf)
  782. {
  783. Path parentPath = fullPath;
  784. DirectoryEntry* newEntryParent = nullptr;
  785. Stack<Path> parentPaths;
  786. do
  787. {
  788. Path newParentPath = parentPath.getParent();
  789. if(newParentPath == parentPath)
  790. break;
  791. LibraryEntry* newEntryParentLib = findEntry(newParentPath);
  792. if(newEntryParentLib != nullptr)
  793. {
  794. assert(newEntryParentLib->type == LibraryEntryType::Directory);
  795. newEntryParent = static_cast<DirectoryEntry*>(newEntryParentLib);
  796. break;
  797. }
  798. parentPaths.push(newParentPath);
  799. parentPath = newParentPath;
  800. } while (true);
  801. assert(newEntryParent != nullptr); // Must exist
  802. if(newHierarchyRoot != nullptr)
  803. *newHierarchyRoot = newEntryParent;
  804. while(!parentPaths.empty())
  805. {
  806. Path curPath = parentPaths.top();
  807. parentPaths.pop();
  808. newEntryParent = addDirectoryInternal(newEntryParent, curPath);
  809. }
  810. if(newHierarchyLeaf != nullptr)
  811. *newHierarchyLeaf = newEntryParent;
  812. }
  813. Path ProjectLibrary::getMetaPath(const Path& path) const
  814. {
  815. Path metaPath = path;
  816. metaPath.setFilename(metaPath.getWFilename() + L".meta");
  817. return metaPath;
  818. }
  819. bool ProjectLibrary::isMeta(const Path& fullPath) const
  820. {
  821. return fullPath.getWExtension() == L".meta";
  822. }
  823. bool ProjectLibrary::isNative(ResourceEntry* resource) const
  824. {
  825. WString extension = resource->path.getWExtension();
  826. return extension == L".asset" || extension == L".prefab";
  827. }
  828. void ProjectLibrary::unloadLibrary()
  829. {
  830. if (!mIsLoaded)
  831. return;
  832. mProjectFolder = Path::BLANK;
  833. mResourcesFolder = Path::BLANK;
  834. clearEntries();
  835. mRootEntry = bs_new<DirectoryEntry>(mResourcesFolder, mResourcesFolder.getWTail(), nullptr);
  836. mReimportQueue.clear();
  837. mDependencies.clear();
  838. gResources().unregisterResourceManifest(mResourceManifest);
  839. mResourceManifest = nullptr;
  840. mIsLoaded = false;
  841. }
  842. void ProjectLibrary::makeEntriesRelative()
  843. {
  844. // Make all paths relative before saving
  845. std::function<void(LibraryEntry*, const Path&)> makeRelative =
  846. [&](LibraryEntry* entry, const Path& root)
  847. {
  848. entry->path.makeRelative(root);
  849. if (entry->type == LibraryEntryType::Directory)
  850. {
  851. DirectoryEntry* dirEntry = static_cast<DirectoryEntry*>(entry);
  852. for (auto& child : dirEntry->mChildren)
  853. makeRelative(child, root);
  854. }
  855. };
  856. Path root = getResourcesFolder();
  857. makeRelative(mRootEntry, root);
  858. }
  859. void ProjectLibrary::makeEntriesAbsolute()
  860. {
  861. std::function<void(LibraryEntry*, const Path&)> makeAbsolute =
  862. [&](LibraryEntry* entry, const Path& root)
  863. {
  864. entry->path.makeAbsolute(root);
  865. if (entry->type == LibraryEntryType::Directory)
  866. {
  867. DirectoryEntry* dirEntry = static_cast<DirectoryEntry*>(entry);
  868. for (auto& child : dirEntry->mChildren)
  869. makeAbsolute(child, root);
  870. }
  871. };
  872. Path root = getResourcesFolder();
  873. makeAbsolute(mRootEntry, root);
  874. }
  875. void ProjectLibrary::saveLibrary()
  876. {
  877. if (!mIsLoaded)
  878. return;
  879. // Make all paths relative before saving
  880. makeEntriesRelative();
  881. std::shared_ptr<ProjectLibraryEntries> libEntries = ProjectLibraryEntries::create(*mRootEntry);
  882. Path libraryEntriesPath = mProjectFolder;
  883. libraryEntriesPath.append(INTERNAL_RESOURCES_DIR);
  884. libraryEntriesPath.append(LIBRARY_ENTRIES_FILENAME);
  885. FileEncoder fs(libraryEntriesPath);
  886. fs.encode(libEntries.get());
  887. // Restore absolute entry paths
  888. makeEntriesAbsolute();
  889. Path resourceManifestPath = mProjectFolder;
  890. resourceManifestPath.append(INTERNAL_RESOURCES_DIR);
  891. resourceManifestPath.append(RESOURCE_MANIFEST_FILENAME);
  892. ResourceManifest::save(mResourceManifest, resourceManifestPath, mProjectFolder);
  893. }
  894. void ProjectLibrary::loadLibrary()
  895. {
  896. unloadLibrary();
  897. mProjectFolder = gEditorApplication().getProjectPath();
  898. mResourcesFolder = mProjectFolder;
  899. mResourcesFolder.append(RESOURCES_DIR);
  900. mRootEntry = bs_new<DirectoryEntry>(mResourcesFolder, mResourcesFolder.getWTail(), nullptr);
  901. Path libraryEntriesPath = mProjectFolder;
  902. libraryEntriesPath.append(INTERNAL_RESOURCES_DIR);
  903. libraryEntriesPath.append(LIBRARY_ENTRIES_FILENAME);
  904. if(FileSystem::exists(libraryEntriesPath))
  905. {
  906. FileDecoder fs(libraryEntriesPath);
  907. std::shared_ptr<ProjectLibraryEntries> libEntries = std::static_pointer_cast<ProjectLibraryEntries>(fs.decode());
  908. *mRootEntry = libEntries->getRootEntry();
  909. for(auto& child : mRootEntry->mChildren)
  910. child->parent = mRootEntry;
  911. mRootEntry->parent = nullptr;
  912. }
  913. // Entries are stored relative to project folder, but we want their absolute paths now
  914. makeEntriesAbsolute();
  915. // Load resource manifest
  916. Path resourceManifestPath = mProjectFolder;
  917. resourceManifestPath.append(INTERNAL_RESOURCES_DIR);
  918. resourceManifestPath.append(RESOURCE_MANIFEST_FILENAME);
  919. if (FileSystem::exists(resourceManifestPath))
  920. mResourceManifest = ResourceManifest::load(resourceManifestPath, mProjectFolder);
  921. else
  922. mResourceManifest = ResourceManifest::create("ProjectLibrary");
  923. gResources().registerResourceManifest(mResourceManifest);
  924. // Load all meta files
  925. Stack<DirectoryEntry*> todo;
  926. todo.push(mRootEntry);
  927. Vector<LibraryEntry*> deletedEntries;
  928. while(!todo.empty())
  929. {
  930. DirectoryEntry* curDir = todo.top();
  931. todo.pop();
  932. for(auto& child : curDir->mChildren)
  933. {
  934. if(child->type == LibraryEntryType::File)
  935. {
  936. ResourceEntry* resEntry = static_cast<ResourceEntry*>(child);
  937. if (FileSystem::isFile(resEntry->path))
  938. {
  939. bool doAddDependencies = true;
  940. if (resEntry->meta == nullptr)
  941. {
  942. Path metaPath = resEntry->path;
  943. metaPath.setFilename(metaPath.getWFilename() + L".meta");
  944. if (FileSystem::isFile(metaPath))
  945. {
  946. FileDecoder fs(metaPath);
  947. std::shared_ptr<IReflectable> loadedMeta = fs.decode();
  948. if (loadedMeta != nullptr && loadedMeta->isDerivedFrom(ProjectResourceMeta::getRTTIStatic()))
  949. {
  950. ProjectResourceMetaPtr resourceMeta = std::static_pointer_cast<ProjectResourceMeta>(loadedMeta);
  951. resEntry->meta = resourceMeta;
  952. }
  953. }
  954. else
  955. {
  956. LOGWRN("Missing meta file: " + metaPath.toString() + ". Triggering reimport.");
  957. reimportResourceInternal(resEntry);
  958. doAddDependencies = false;
  959. }
  960. }
  961. if (resEntry->meta != nullptr)
  962. mUUIDToPath[resEntry->meta->getUUID()] = resEntry->path;
  963. if (doAddDependencies)
  964. addDependencies(resEntry);
  965. }
  966. else
  967. deletedEntries.push_back(resEntry);
  968. }
  969. else if(child->type == LibraryEntryType::Directory)
  970. {
  971. if (FileSystem::isDirectory(child->path))
  972. todo.push(static_cast<DirectoryEntry*>(child));
  973. else
  974. deletedEntries.push_back(child);
  975. }
  976. }
  977. }
  978. // Remove entries that no longer have corresponding files
  979. for (auto& deletedEntry : deletedEntries)
  980. {
  981. if (deletedEntry->type == LibraryEntryType::File)
  982. {
  983. ResourceEntry* resEntry = static_cast<ResourceEntry*>(deletedEntry);
  984. deleteResourceInternal(resEntry);
  985. }
  986. else
  987. {
  988. DirectoryEntry* dirEntry = static_cast<DirectoryEntry*>(deletedEntry);
  989. deleteDirectoryInternal(dirEntry);
  990. }
  991. }
  992. mIsLoaded = true;
  993. }
  994. void ProjectLibrary::clearEntries()
  995. {
  996. if (mRootEntry == nullptr)
  997. return;
  998. std::function<void(LibraryEntry*)> deleteRecursive =
  999. [&](LibraryEntry* entry)
  1000. {
  1001. if (entry->type == LibraryEntryType::Directory)
  1002. {
  1003. DirectoryEntry* dirEntry = static_cast<DirectoryEntry*>(entry);
  1004. for (auto& child : dirEntry->mChildren)
  1005. deleteRecursive(child);
  1006. }
  1007. bs_delete(entry);
  1008. };
  1009. deleteRecursive(mRootEntry);
  1010. mRootEntry = nullptr;
  1011. }
  1012. void ProjectLibrary::doOnEntryRemoved(const LibraryEntry* entry)
  1013. {
  1014. if (!onEntryRemoved.empty())
  1015. onEntryRemoved(entry->path);
  1016. if (entry->type == LibraryEntryType::File)
  1017. {
  1018. const ResourceEntry* resEntry = static_cast<const ResourceEntry*>(entry);
  1019. queueDependantForReimport(resEntry);
  1020. removeDependencies(resEntry);
  1021. }
  1022. }
  1023. void ProjectLibrary::doOnEntryAdded(const LibraryEntry* entry)
  1024. {
  1025. if (!onEntryAdded.empty())
  1026. onEntryAdded(entry->path);
  1027. if (entry->type == LibraryEntryType::File)
  1028. {
  1029. const ResourceEntry* resEntry = static_cast<const ResourceEntry*>(entry);
  1030. queueDependantForReimport(resEntry);
  1031. }
  1032. }
  1033. Vector<Path> ProjectLibrary::getImportDependencies(const ResourceEntry* entry)
  1034. {
  1035. Vector<Path> output;
  1036. if (entry->meta == nullptr)
  1037. return output;
  1038. if (entry->meta->getTypeID() == TID_Shader)
  1039. {
  1040. SPtr<ShaderMetaData> metaData = std::static_pointer_cast<ShaderMetaData>(entry->meta->getResourceMetaData());
  1041. for (auto& include : metaData->includes)
  1042. output.push_back(include);
  1043. }
  1044. return output;
  1045. }
  1046. void ProjectLibrary::addDependencies(const ResourceEntry* entry)
  1047. {
  1048. Vector<Path> dependencies = getImportDependencies(entry);
  1049. for (auto& dependency : dependencies)
  1050. mDependencies[dependency].push_back(entry->path);
  1051. }
  1052. void ProjectLibrary::removeDependencies(const ResourceEntry* entry)
  1053. {
  1054. Vector<Path> dependencies = getImportDependencies(entry);
  1055. for (auto& dependency : dependencies)
  1056. {
  1057. Vector<Path>& curDependencies = mDependencies[dependency];
  1058. auto iterRemove = std::remove_if(curDependencies.begin(), curDependencies.end(),
  1059. [&](const Path& x)
  1060. {
  1061. return x == entry->path;
  1062. });
  1063. curDependencies.erase(iterRemove, curDependencies.end());
  1064. }
  1065. }
  1066. void ProjectLibrary::queueDependantForReimport(const ResourceEntry* entry)
  1067. {
  1068. auto iterFind = mDependencies.find(entry->path);
  1069. if (iterFind == mDependencies.end())
  1070. return;
  1071. for (auto& dependency : iterFind->second)
  1072. mReimportQueue.insert(dependency);
  1073. }
  1074. BS_ED_EXPORT ProjectLibrary& gProjectLibrary()
  1075. {
  1076. return ProjectLibrary::instance();
  1077. }
  1078. }