public static CompressTask UnCompressAsync(string zipPath, string outPath) { CompressTask task = new CompressTask(); Loom.RunAsync(() => UnZipFile(zipPath, outPath, out task.Error, out task.Progress)); return(task); }
public static int Compress(ReadOnlySpan <byte> read, Span <byte> w, CompressTask task, int cur = 0) { DmadataRecord dmadataRec = GetDmadataRec(read, task.Dmadata); var dmadata = GetDmadataRecords(read, task.Dmadata); for (int i = 0; i < dmadata.Count; i++) { if (i % 50 == 0) { Console.WriteLine($"File {i}"); } var dmarec = dmadata[i]; FileAddress vrom = dmarec.VRom; FileAddress rom = dmarec.Rom; if (rom.Start < 0) { continue; } ReadOnlySpan <byte> file = read.Slice(rom.Start, vrom.Size); //if file should be compressed if (!task.Exclusions.Contains(i)) { int size = Yaz.Encode(file.ToArray(), vrom.Size, out byte[] comp); if (size > 0) { Span <byte> c = new(comp, 0, size); c.CopyTo(w.Slice(cur, size)); dmarec.Rom = new FileAddress(cur, cur + size); cur += size; continue; } } file.CopyTo(w.Slice(cur, vrom.Size)); dmarec.Rom = new FileAddress(cur, 0); cur += vrom.Size; } WriteDmadataRecords(w.Slice(dmadataRec.Rom.Start, dmadataRec.VRom.Size), dmadata); return(cur); }