protected override ITexture2D PlatformLoadFromFile(uint id, IReadOnlyFile file) { _logger.LogDebug($"Loading texture {id} [{file}]"); using (var fs = file.OpenRead()) { var texture = Texture2D.FromStream(_device, fs); return(new PlatformTexture2D(id, _device, texture)); } }
private async Task <IFileSystemNode> CacheFile(IReadOnlyFile sourceFile) { //todo: check if cached // create directory await _cache.GetOrCreateDirectory(sourceFile.Path.GetDirectoryPath()); // copy source to target var targetFile = await _cache.GetOrCreateFile(sourceFile.Path); await using var targetStream = await targetFile.OpenWrite(); await using var sourceStream = await sourceFile.OpenRead(); await sourceStream.CopyToAsync(targetStream); return(targetFile); }