BsProjectLibrary.cpp 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  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. onEntryImport(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;
  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. };
  995. FileSystem::iterate(internalResourcesFolder, &processFile);
  996. for (auto& entry : toDelete)
  997. FileSystem::remove(entry);
  998. mIsLoaded = true;
  999. }
  1000. void ProjectLibrary::clearEntries()
  1001. {
  1002. if (mRootEntry == nullptr)
  1003. return;
  1004. std::function<void(LibraryEntry*)> deleteRecursive =
  1005. [&](LibraryEntry* entry)
  1006. {
  1007. if (entry->type == LibraryEntryType::Directory)
  1008. {
  1009. DirectoryEntry* dirEntry = static_cast<DirectoryEntry*>(entry);
  1010. for (auto& child : dirEntry->mChildren)
  1011. deleteRecursive(child);
  1012. }
  1013. bs_delete(entry);
  1014. };
  1015. deleteRecursive(mRootEntry);
  1016. mRootEntry = nullptr;
  1017. }
  1018. Vector<Path> ProjectLibrary::getImportDependencies(const ResourceEntry* entry)
  1019. {
  1020. Vector<Path> output;
  1021. if (entry->meta == nullptr)
  1022. return output;
  1023. if (entry->meta->getTypeID() == TID_Shader)
  1024. {
  1025. SPtr<ShaderMetaData> metaData = std::static_pointer_cast<ShaderMetaData>(entry->meta->getResourceMetaData());
  1026. for (auto& include : metaData->includes)
  1027. output.push_back(include);
  1028. }
  1029. return output;
  1030. }
  1031. void ProjectLibrary::addDependencies(const ResourceEntry* entry)
  1032. {
  1033. Vector<Path> dependencies = getImportDependencies(entry);
  1034. for (auto& dependency : dependencies)
  1035. mDependencies[dependency].push_back(entry->path);
  1036. }
  1037. void ProjectLibrary::removeDependencies(const ResourceEntry* entry)
  1038. {
  1039. Vector<Path> dependencies = getImportDependencies(entry);
  1040. for (auto& dependency : dependencies)
  1041. {
  1042. Vector<Path>& curDependencies = mDependencies[dependency];
  1043. auto iterRemove = std::remove_if(curDependencies.begin(), curDependencies.end(),
  1044. [&](const Path& x)
  1045. {
  1046. return x == entry->path;
  1047. });
  1048. curDependencies.erase(iterRemove, curDependencies.end());
  1049. }
  1050. }
  1051. void ProjectLibrary::reimportDependants(const Path& entryPath)
  1052. {
  1053. auto iterFind = mDependencies.find(entryPath);
  1054. if (iterFind == mDependencies.end())
  1055. return;
  1056. // Make a copy since we might modify this list during reimport
  1057. Vector<Path> dependencies = iterFind->second;
  1058. for (auto& dependency : dependencies)
  1059. {
  1060. LibraryEntry* entry = findEntry(dependency);
  1061. if (entry != nullptr && entry->type == LibraryEntryType::File)
  1062. {
  1063. ResourceEntry* resEntry = static_cast<ResourceEntry*>(entry);
  1064. ImportOptionsPtr importOptions;
  1065. if (resEntry->meta != nullptr)
  1066. importOptions = resEntry->meta->getImportOptions();
  1067. reimportResourceInternal(resEntry, importOptions, true);
  1068. }
  1069. }
  1070. }
  1071. BS_ED_EXPORT ProjectLibrary& gProjectLibrary()
  1072. {
  1073. return ProjectLibrary::instance();
  1074. }
  1075. }