Filesystem directory features and bugfix #191

Merged
XiaoQiDigipen merged 3 commits from SP3-13-Assets-Manager into main 2022-11-11 10:56:44 +08:00
3 changed files with 64 additions and 3 deletions
Showing only changes of commit 9fe5dc385b - Show all commits

View File

@ -38,6 +38,41 @@ namespace SHADE
return false;
}
bool SHFileSystem::MatchExtention(FileExt raw, FileExt compiled) noexcept
{
if (raw == GLSL_EXTENSION)
{
if (compiled == SHADER_EXTENSION ||
compiled == SHADER_BUILT_IN_EXTENSION)
{
return true;
}
}
else if (raw == DDS_EXTENSION)
{
if (compiled == TEXTURE_EXTENSION)
{
return true;
}
}
else if (raw == FBX_EXTENSION)
{
if (compiled == MODEL_EXTENSION)
{
return true;
}
}
else if (raw == GLTF_EXTENSION)
{
if (compiled == MODEL_EXTENSION)
{
return true;
}
}
return false;
}
void SHFileSystem::BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept
{
std::stack<FolderPointer> folderStack;
@ -52,6 +87,7 @@ namespace SHADE
std::vector<SHAsset> assets;
// Get all subfolders/files in this current folder
for (auto& dirEntry : std::filesystem::directory_iterator(folder->path))
{
auto path = dirEntry.path();
@ -60,8 +96,6 @@ namespace SHADE
{
if (path.extension().string() == META_EXTENSION)
{
//auto asset = SHAssetMetaHandler::RetrieveMetaData(path);
//assetCollection.insert({ asset.id, asset });
assets.push_back(SHAssetMetaHandler::RetrieveMetaData(path));
}
else
@ -77,6 +111,7 @@ namespace SHADE
continue;
}
// If item is folder
auto newFolder{ folder->CreateSubFolderHere(path.stem().string()) };
folderStack.push(newFolder);
}
@ -97,6 +132,30 @@ namespace SHADE
}
}
}
for (auto i {0}; i < folder->files.size(); ++i)
{
auto& file = folder->files[i];
if (file.compilable)
{
for (auto j{ 0 }; j < folder->files.size(); ++j)
{
auto& check = folder->files[j];
if (i == j || check.compilable)
{
continue;
}
if (file.name == check.name)
{
if (MatchExtention(file.ext, check.ext))
{
file.compiled = true;
}
}
}
}
}
}
}

View File

@ -24,5 +24,6 @@ namespace SHADE
private:
static bool DeleteFolder(FolderPointer location) noexcept;
static bool IsCompilable(std::string ext) noexcept;
static bool MatchExtention(FileExt raw, FileExt compiled) noexcept;
};
}

View File

@ -33,7 +33,8 @@ namespace SHADE
FilePath path;
FileExt ext;
SHAsset const* assetMeta;
bool compilable;
bool compilable;
bool compiled;
};
class SHFolder