Ejemplo n.º 1
0
        private static async Task <Mod> CreateMod(DirectoryInfo modFolder, Action <FileSignature, Uri> fileAction)
        {
            Console.WriteLine($"Processing {modFolder.FullName}");
            var hashing = new HashingService(new XXHash64());
            var obs     = hashing.GetFileHashes(modFolder, CancellationToken.None);
            var mod     = new Mod
            {
                Files   = new Dictionary <Uri, FileSignature>(),
                Name    = modFolder.Name,
                Version = "1.0"
            };

            foreach (var lazy in obs)
            {
                var fileHash = await lazy.Value;
                Console.WriteLine($"Processing {fileHash.File.FullName}");
                var fileSig = new FileSignature(fileHash.Hash, fileHash.File.Length);
                mod.Files.Add(new Uri(modFolder.FullName).MakeRelativeUri(new Uri(fileHash.File.FullName)),
                              fileSig);
                fileAction(fileSig, new Uri(fileHash.File.FullName));
            }

            return(mod);
        }