コード例 #1
0
ファイル: TextureFactoryMG.cs プロジェクト: xposure/Worm
 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));
     }
 }
コード例 #2
0
        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);
        }