From d678c4bc33314a5495d75419baadf3cb416c702b Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 28 Apr 2025 13:43:57 -0400 Subject: [PATCH] refactor(resource-manager): minor style changes and comments --- src/resource/private/resourceManager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/resource/private/resourceManager.cpp b/src/resource/private/resourceManager.cpp index 72c667e..10de1f3 100644 --- a/src/resource/private/resourceManager.cpp +++ b/src/resource/private/resourceManager.cpp @@ -39,11 +39,11 @@ ResourceManager::ResourceManager() { m_dataDir = m_config.get("Data:Dir", defaultDataDir); // -- Get the index file path using filesytem to make it a system safe path std::string indexFilePath = m_dataDir + "/index.yaml"; - std::filesystem::path indexFile(indexFilePath); + // TODO Add checks to make sure data dir exists and index.yaml exists + const std::filesystem::path indexFile(indexFilePath); m_resourceConfig.loadConfig(indexFile.string()); - std::vector assets = m_resourceConfig.keys(); - for (auto key : assets ) { + for (const auto key : m_resourceConfig.keys() ) { load(key); } } @@ -69,14 +69,15 @@ bool ResourceManager::loadResource(std::string& name) { } bool ResourceManager::load(const std::string& name) { + // TODO : make this path system more system agnostic const std::string resourcePath = m_dataDir + "/" + m_resourceConfig.get(name); - std::filesystem::path resourceFile(resourcePath); + const std::filesystem::path resourceFile(resourcePath); if (!std::filesystem::exists(resourceFile)) { LOG_ERROR(m_logger, "Resource file not found: {}", resourceFile.string()); return false; } LOG_INFO(m_logger, "Loading resource: {}", resourceFile.string()); - if (m_resources.find(name) != m_resources.end()) { + if (m_resources.contains(name)) { LOG_INFO(m_logger, "Resource already loaded: {}", name); return true; }