/// <summary> /// Extracts the specified j input stream. /// </summary> /// <param name="jInputStream">The j input stream.</param> /// <param name="destinationDirectory">The destination directory.</param> /// <param name="truncatePaths">if set to <c>true</c> [truncate paths].</param> public static void Extract(java.io.InputStream jInputStream, string destinationDirectory, bool truncatePaths) { if (string.IsNullOrEmpty(destinationDirectory)) { throw new ArgumentException("destinationDirectory"); } destinationDirectory = FileSystemUtilities.EnsureDirectoryEnding(destinationDirectory); ReadZipStream(jInputStream, delegate(ZipEntryE entry, ZipEntryInputStream zipEntryStream, object rock) { zipEntryStream.WriteTo(destinationDirectory + entry.getName(truncatePaths)); }, null); }
/// <summary> /// Gets the relative location. /// </summary> /// <param name="fromPath">From path.</param> /// <param name="toPath">To path.</param> /// <returns></returns> public static string GetRelativeLocation(string fromPath, string toPath) { if (System.IO.File.Exists(fromPath)) { fromPath = new FileInfo(fromPath).DirectoryName; } if (Directory.Exists(fromPath)) { fromPath = FileSystemUtilities.EnsureDirectoryEnding(fromPath); } if (Directory.Exists(toPath)) { toPath = FileSystemUtilities.EnsureDirectoryEnding(toPath); } if (toPath.StartsWith(fromPath)) { return(toPath.Substring(fromPath.Length)); } throw new NotImplementedException(); }