Function to call to refresh asset directory
This commit is contained in:
parent
0e5609995f
commit
03f9c593b6
|
@ -373,6 +373,13 @@ namespace SHADE
|
||||||
return folderRoot;
|
return folderRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHAssetManager::RefreshDirectory() noexcept
|
||||||
|
{
|
||||||
|
SHFileSystem::DestroyDirectory(folderRoot);
|
||||||
|
assetCollection.clear();
|
||||||
|
BuildAssetCollection();
|
||||||
|
}
|
||||||
|
|
||||||
bool SHAssetManager::IsRecognised(char const* ext) noexcept
|
bool SHAssetManager::IsRecognised(char const* ext) noexcept
|
||||||
{
|
{
|
||||||
for (auto const& e : EXTENSIONS)
|
for (auto const& e : EXTENSIONS)
|
||||||
|
|
|
@ -90,6 +90,7 @@ namespace SHADE
|
||||||
static void CompileAsset(AssetPath const& path, bool genMeta) noexcept;
|
static void CompileAsset(AssetPath const& path, bool genMeta) noexcept;
|
||||||
|
|
||||||
static FolderPointer GetRootFolder() noexcept;
|
static FolderPointer GetRootFolder() noexcept;
|
||||||
|
static void RefreshDirectory() noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "SHFileSystem.h"
|
#include "SHFileSystem.h"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
#include "Assets/SHAssetMetaHandler.h"
|
#include "Assets/SHAssetMetaHandler.h"
|
||||||
|
|
||||||
|
@ -39,15 +40,15 @@ namespace SHADE
|
||||||
|
|
||||||
void SHFileSystem::BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept
|
void SHFileSystem::BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept
|
||||||
{
|
{
|
||||||
std::queue<FolderPointer> folderQueue;
|
std::stack<FolderPointer> folderStack;
|
||||||
root = new SHFolder("root");
|
root = new SHFolder("root");
|
||||||
root->path = path;
|
root->path = path;
|
||||||
folderQueue.push(root);
|
folderStack.push(root);
|
||||||
|
|
||||||
while (!folderQueue.empty())
|
while (!folderStack.empty())
|
||||||
{
|
{
|
||||||
auto const folder = folderQueue.front();
|
auto const folder = folderStack.top();
|
||||||
folderQueue.pop();
|
folderStack.pop();
|
||||||
|
|
||||||
std::vector<SHAsset> assets;
|
std::vector<SHAsset> assets;
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
auto newFolder{ folder->CreateSubFolderHere(path.stem().string()) };
|
auto newFolder{ folder->CreateSubFolderHere(path.stem().string()) };
|
||||||
folderQueue.push(newFolder);
|
folderStack.push(newFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& asset : assets)
|
for (auto const& asset : assets)
|
||||||
|
@ -98,4 +99,23 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHFileSystem::DestroyDirectory(FolderPointer root) noexcept
|
||||||
|
{
|
||||||
|
std::stack<FolderPointer> folderStack;
|
||||||
|
folderStack.push(root);
|
||||||
|
|
||||||
|
while(!folderStack.empty())
|
||||||
|
{
|
||||||
|
auto const folder = folderStack.top();
|
||||||
|
folderStack.pop();
|
||||||
|
|
||||||
|
for (auto const& ptr : folder->subFolders)
|
||||||
|
{
|
||||||
|
folderStack.push(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete folder;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept;
|
static void BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept;
|
||||||
|
static void DestroyDirectory(FolderPointer root) noexcept;
|
||||||
private:
|
private:
|
||||||
static bool DeleteFolder(FolderPointer location) noexcept;
|
static bool DeleteFolder(FolderPointer location) noexcept;
|
||||||
static bool IsCompilable(std::string ext) noexcept;
|
static bool IsCompilable(std::string ext) noexcept;
|
||||||
|
|
Loading…
Reference in New Issue