diff --git a/Juliet/src/Core/HAL/Filesystem/Filesystem.cpp b/Juliet/src/Core/HAL/Filesystem/Filesystem.cpp index dc1af03..bcfd8ce 100644 --- a/Juliet/src/Core/HAL/Filesystem/Filesystem.cpp +++ b/Juliet/src/Core/HAL/Filesystem/Filesystem.cpp @@ -37,52 +37,49 @@ String GetAssetBasePath() String GetAssetPath(NonNullPtr arena, AssetType type, String filename) { + // ICI on va vouloir 1) avoir une fonction create file path a partir de base + file qui fait un string copy + // On va passer le path au clean path Assert(IsValid(filename)); - String asset_path = {}; + char buffer[MAX_PATH]; + size_t totalSize = MAX_PATH; + switch (type) { case AssetType::Shader: { Assert(IsValid(CachedShaderBasePath)); - size_t totalSize = CachedShaderBasePath.Size + filename.Size + 1; - char* buffer = ArenaPushArray(arena, totalSize); - Assert(buffer); + totalSize = CachedShaderBasePath.Size + filename.Size + 1; juliet_snprintf(buffer, totalSize, "%s%s", CStr(CachedShaderBasePath), CStr(filename)); - asset_path = { buffer, totalSize - 1 }; } break; case AssetType::Config: { Assert(IsValid(CachedAssetBasePath)); - constexpr const char* kConfig_str = "config/"; - constexpr size_t kConfig_size = sizeof(kConfig_str) - 1; + constexpr char kConfig_str[] = "config/"; + constexpr size_t kConfig_size = sizeof(kConfig_str) - 1; - size_t totalSize = CachedAssetBasePath.Size + kConfig_size + filename.Size + 1; - char* buffer = ArenaPushArray(arena, totalSize); - Assert(buffer); + totalSize = CachedAssetBasePath.Size + kConfig_size + filename.Size + 1; juliet_snprintf(buffer, totalSize, "%s%s%s", CStr(CachedAssetBasePath), kConfig_str, CStr(filename)); - asset_path = { buffer, totalSize - 1 }; } break; + case AssetType::JAsset: [[fallthrough]]; default: { Assert(IsValid(CachedAssetBasePath)); - size_t totalSize = CachedAssetBasePath.Size + filename.Size + 1; - char* buffer = ArenaPushArray(arena, totalSize); - Assert(buffer); + totalSize = CachedAssetBasePath.Size + filename.Size + 1; juliet_snprintf(buffer, totalSize, "%s%s", CStr(CachedAssetBasePath), CStr(filename)); - asset_path = { buffer, totalSize - 1 }; } break; } + String asset_path = CleanPath(arena, { buffer, totalSize - 1 }); return asset_path; }