BsProjectLibrary.cpp 37 KB

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