private static void AddZipEntry(java.util.zip.ZipFile zf, VfsDirectory root, java.util.zip.ZipEntry entry) { if (entry.isDirectory()) { return; } string[] path = entry.getName().Split('/'); VfsDirectory dir = root; for (int i = 0; i < path.Length - 1; i++) { VfsDirectory existing = dir.GetEntry(path[i]) as VfsDirectory; if (existing == null) { existing = dir.AddDirectory(path[i]); } dir = existing; } dir.Add(path[path.Length - 1], new VfsZipEntry(zf, entry)); }
internal ZipEntryStream(java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry entry) { this.zipFile = zipFile; this.entry = entry; inp = zipFile.getInputStream(entry); }
internal VfsZipEntry(java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry entry) { this.zipFile = zipFile; this.entry = entry; }
private void saveStreamToZip(string name, System.IO.Stream data, java.util.zip.ZipOutputStream zos) { java.util.zip.ZipEntry ze = new java.util.zip.ZipEntry(name); zos.putNextEntry(ze); byte[] buffer = new byte[1024]; int ReadBytes; while ((ReadBytes = data.Read(buffer, 0, 1024)) > 0) try { byte[] b2 = new byte[ReadBytes]; for (int i = 0; i < ReadBytes; i++) b2[i] = (byte)buffer[i]; zos.write(b2, 0, ReadBytes); } catch (System.IO.IOException e) { File.AppendAllText("log_SAve.txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ": " + name + Environment.NewLine); break; } zos.closeEntry(); }
private bool AddToZip(java.io.FileOutputStream fos, java.util.zip.ZipOutputStream zos, string sourceFile, string destName) { try { Thread.Sleep(6000); java.io.FileInputStream fis = new java.io.FileInputStream(sourceFile); java.util.zip.ZipEntry ze = new java.util.zip.ZipEntry(destName); zos.putNextEntry(ze); byte[] buffer = new byte[1024]; int len; while ((len = fis.read(buffer)) >= 0) { zos.write(buffer, 0, len); } zos.closeEntry(); fis.close(); } catch (Exception) { File.AppendAllText("log_save.txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ": " + sourceFile + Environment.NewLine); AddToZip( fos, zos, sourceFile, destName); } return true; }