code review changes and fixes
This commit is contained in:
@@ -40,8 +40,9 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
|
||||
Array<char> ResourceLoaderAppDirLinux::GetResource(const std::string& resourceName)
|
||||
Array<char> ResourceLoaderAppDirLinux::GetResource(const std::string& resourceName, std::string& resourcePath)
|
||||
{
|
||||
return Utils::ReadFile(GetAppDir() + resourceName, true);
|
||||
resourcePath = GetAppDir() + resourceName;
|
||||
return Utils::ReadFile(resourcePath, true);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,6 @@ namespace OpenVulkano
|
||||
class ResourceLoaderAppDirLinux final : public ResourceLoader
|
||||
{
|
||||
public:
|
||||
Array<char> GetResource(const std::string& resourceName) override;
|
||||
Array<char> GetResource(const std::string& resourceName, std::string& resourcePath) override;
|
||||
};
|
||||
}
|
||||
@@ -15,13 +15,13 @@ namespace OpenVulkano
|
||||
std::vector<std::unique_ptr<ResourceLoader>> m_loaders;
|
||||
|
||||
public:
|
||||
Array<char> GetResource(const std::string& resourceName) override
|
||||
Array<char> GetResource(const std::string& resourceName, std::string& resourcePath) override
|
||||
{
|
||||
for(auto& loader : m_loaders)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto res = loader->GetResource(resourceName);
|
||||
auto res = loader->GetResource(resourceName, resourcePath);
|
||||
if (!res.Empty()) return res;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace OpenVulkano
|
||||
public:
|
||||
virtual ~ResourceLoader() = default;
|
||||
|
||||
virtual Array<char> GetResource(const std::string& resourceName) = 0;
|
||||
virtual Array<char> GetResource(const std::string& resourceName, std::string& resourcePath) = 0;
|
||||
|
||||
static ResourceLoader& GetInstance();
|
||||
|
||||
|
||||
@@ -90,11 +90,12 @@ namespace OpenVulkano
|
||||
return Array<char>(buffer);
|
||||
}
|
||||
|
||||
Array<char> WebResourceLoader::GetResource(const std::string& resourceName)
|
||||
Array<char> WebResourceLoader::GetResource(const std::string& resourceName, std::string& resourcePath)
|
||||
{
|
||||
if (IsUrl(resourceName))
|
||||
{
|
||||
std::filesystem::path cacheFilePath = GetCacheFilePath(resourceName);
|
||||
resourcePath = resourceName;
|
||||
if (std::filesystem::exists(cacheFilePath)) { return Utils::ReadFile(cacheFilePath.string()); }
|
||||
else { return DownloadResource(resourceName); }
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ namespace OpenVulkano
|
||||
|
||||
WebResourceLoader();
|
||||
~WebResourceLoader();
|
||||
Array<char> GetResource(const std::string& resourceName) override;
|
||||
Array<char> GetResource(const std::string& resourceName, std::string& resourcePath) override;
|
||||
};
|
||||
}
|
||||
@@ -38,8 +38,9 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
|
||||
Array<char> ResourceLoaderAppDirWindows::GetResource(const std::string& resourceName)
|
||||
Array<char> ResourceLoaderAppDirWindows::GetResource(const std::string& resourceName, std::string& resourcePath)
|
||||
{
|
||||
return Utils::ReadFile(GetAppDir() + resourceName);
|
||||
resourcePath = GetAppDir() + resourceName;
|
||||
return Utils::ReadFile(resourcePath);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,6 @@ namespace OpenVulkano
|
||||
class ResourceLoaderAppDirWindows final : public ResourceLoader
|
||||
{
|
||||
public:
|
||||
Array<char> GetResource(const std::string& resourceName) override;
|
||||
Array<char> GetResource(const std::string& resourceName, std::string& resourcePath) override;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user