private LoadedResourceCache GetResourceCache(PageableResource resource) { if (!resource.GetLocation(out var location)) { return(null); } if (!LoadedResourceCaches.TryGetValue(location, out LoadedResourceCache cache)) { var file = new FileInfo(Path.Combine(Directory.FullName, ResourceCacheNames[location])); if (!file.Exists && file.Name == "resources_b.dat") { file = new FileInfo(Path.Combine(Directory.FullName, "video.dat")); } using (var stream = file.OpenRead()) { cache = new LoadedResourceCache { File = file, Cache = new ResourceCache(stream) }; } } return(cache); }
/// <summary> /// Gets a resource cache file descriptor for the specified <see cref="ResourceLocation"/>. /// </summary> /// <param name="location">The location of the resource file.</param> /// <returns></returns> public ResourceCache GetResourceCache(ResourceLocation location) { if (!LoadedResourceCaches.TryGetValue(location, out LoadedResourceCache cache)) { var file = new FileInfo(Path.Combine(Directory.FullName, ResourceCacheNames[location])); using (var stream = file.OpenRead()) { cache = new LoadedResourceCache { File = file, Cache = new ResourceCache(stream) }; } LoadedResourceCaches[location] = cache; } return(cache.Cache); }
private LoadedResourceCache LoadResourceCache(ResourceLocation location) { if (!LoadedResourceCaches.TryGetValue(location, out LoadedResourceCache cache)) { ResourceCacheHaloOnline resourceCache; var file = new FileInfo(Path.Combine(Directory.FullName, ResourceCacheNames[location])); using (var stream = file.OpenRead()) { resourceCache = new ResourceCacheHaloOnline(Cache.Version, stream); } cache = new LoadedResourceCache { File = file, Cache = resourceCache }; LoadedResourceCaches[location] = cache; } return(cache); }