-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathResourceManifest.cpp
62 lines (49 loc) · 1.48 KB
/
ResourceManifest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "ResourceManifest.hpp"
#include <Resources/BsResource.h>
#include "ImportPath.hpp"
#include <FileSystem/BsFileSystem.h>
#include <Resources/BsResourceManifest.h>
#include <Resources/BsResources.h>
constexpr auto GOTHIC_CACHE_MANIFEST_NAME = "gothic-cache";
static bs::SPtr<bs::ResourceManifest> s_GothicCache;
namespace BsZenLib
{
void LoadResourceManifest()
{
bs::Path manifestPath = BsZenLib::GothicPathToCachedManifest(GOTHIC_CACHE_MANIFEST_NAME);
if (bs::FileSystem::exists(manifestPath))
{
s_GothicCache = bs::ResourceManifest::load(manifestPath, BsZenLib::GetCacheDirectory());
bs::gResources().registerResourceManifest(s_GothicCache);
}
else
{
s_GothicCache = bs::ResourceManifest::create(GOTHIC_CACHE_MANIFEST_NAME);
}
}
void AddToResourceManifest(bs::HResource resource, const bs::Path& filePath)
{
if (!s_GothicCache)
{
LoadResourceManifest();
}
s_GothicCache->registerResource(resource.getUUID(), filePath);
}
void SaveResourceManifest()
{
if (!s_GothicCache)
{
LoadResourceManifest();
}
bs::Path manifestPath = BsZenLib::GothicPathToCachedManifest(GOTHIC_CACHE_MANIFEST_NAME);
bs::ResourceManifest::save(s_GothicCache, manifestPath, BsZenLib::GetCacheDirectory());
}
bool HasCachedResource(const bs::Path& filePath)
{
if (!s_GothicCache)
{
LoadResourceManifest();
}
return s_GothicCache->filePathExists(filePath);
}
} // namespace BsZenLib