public static void Extract(ArchiveInputStream stream, string outDir, Parte p, long totalData) { ArchiveEntry entrada = null; byte[] buffer = new byte[Consts.BUFFER_LENGTH]; int leidos = 0; if (p != null) { p.OnProgress (0, 1); } while ((entrada = stream.GetNextEntry ()) != null) { if (entrada.IsDirectory) { continue; } if (entrada.IsLink){ // TODO Implementar el link. continue; } leidos = 0; try { Stream s = Dalle.Utilidades.UtilidadesFicheros.CreateWriter (outDir + Path.DirectorySeparatorChar + entrada.Name); while ((leidos = stream.Read (buffer)) > 0) { s.Write (buffer, 0, leidos); if (leidos > 0 && p != null) { if (totalData > 0) { p.OnProgress (stream.Position, totalData); } else if (stream.Length > 0) { p.OnProgress (stream.Position, stream.Length); } } } s.Close (); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } if (p != null) { if (totalData > 0) { p.OnProgress (stream.Position, totalData); } else if (stream.Length > 0) { p.OnProgress (stream.Position, stream.Length); } else { p.OnProgress (1, 1); } } stream.Close (); }
public static void Extract(ArchiveInputStream stream, string outDir, Parte p) { Extract (stream, outDir, p, -1); }