remove last 3 dependencies

This commit is contained in:
pijemcolu
2017-10-19 12:11:07 +02:00
parent 8a114a105e
commit bc32ff31d4
4 changed files with 23 additions and 125 deletions

View File

@@ -5,7 +5,6 @@ using System.Globalization;
using System.IO;
using System.Xml;
using System.Linq;
using ICSharpCode.SharpZipLib.Zip;
using Umbraco.Core;
using Umbraco.Core.Auditing;
using Umbraco.Core.IO;
@@ -14,6 +13,7 @@ using Umbraco.Core.Packaging;
using umbraco.cms.businesslogic.web;
using umbraco.BusinessLogic;
using System.Diagnostics;
using System.IO.Compression;
using umbraco.cms.businesslogic.template;
using umbraco.interfaces;
using Umbraco.Core.Events;
@@ -520,7 +520,7 @@ namespace umbraco.cms.businesslogic.packager
/// <param name="tempDir"></param>
public void InstallCleanUp(int packageId, string tempDir)
{
if (Directory.Exists(tempDir))
{
Directory.Delete(tempDir, true);
@@ -751,8 +751,6 @@ namespace umbraco.cms.businesslogic.packager
private static string UnPack(string zipName, bool deleteFile)
{
// Unzip
//the temp directory will be the package GUID - this keeps it consistent!
//the zipName is always the package Guid.umb
@@ -765,48 +763,14 @@ namespace umbraco.cms.businesslogic.packager
if (Directory.Exists(tempDir)) Directory.Delete(tempDir, true);
Directory.CreateDirectory(tempDir);
var s = new ZipInputStream(File.OpenRead(zipName));
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
string fileName = Path.GetFileName(theEntry.Name);
if (fileName != String.Empty)
{
FileStream streamWriter = File.Create(tempDir + Path.DirectorySeparatorChar + fileName);
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = s.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
// Clean up
s.Close();
ZipFile.ExtractToDirectory(zipName, tempDir);
if (deleteFile)
{
File.Delete(zipName);
}
return tempDir;
}
#endregion

View File

@@ -11,13 +11,13 @@ using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.IO;
using System.IO.Compression;
using System.Xml;
using umbraco.cms.businesslogic.template;
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.macro;
using ICSharpCode.SharpZipLib.Zip;
using Umbraco.Core;
using Umbraco.Core.IO;
@@ -278,58 +278,24 @@ namespace umbraco.cms.businesslogic.packager
/// <param name="savePath">The save path.</param>
public static void ZipPackage(string Path, string savePath)
{
string OutPath = savePath;
ArrayList ar = GenerateFileList(Path);
// generate file list
// find number of chars to remove from orginal file path
int TrimLength = (Directory.GetParent(Path)).ToString().Length;
TrimLength += 1;
//remove '\'
FileStream ostream;
byte[] obuffer;
ZipOutputStream oZipStream = new ZipOutputStream(System.IO.File.Create(OutPath));
// create zip stream
oZipStream.SetLevel(9);
// 9 = maximum compression level
ZipEntry oZipEntry;
foreach (string Fil in ar) // for each file, generate a zipentry
using (var memoryStream = new MemoryStream())
{
oZipEntry = new ZipEntry(Fil.Remove(0, TrimLength));
oZipStream.PutNextEntry(oZipEntry);
if (!Fil.EndsWith(@"/")) // if a file ends with '/' its a directory
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create))
{
ostream = File.OpenRead(Fil);
obuffer = new byte[ostream.Length];
// byte buffer
ostream.Read(obuffer, 0, obuffer.Length);
oZipStream.Write(obuffer, 0, obuffer.Length);
ostream.Close();
foreach (string file in ar)
{
if (file.EndsWith(@"/") != true) // it's not a directory
{
archive.CreateEntryFromFile(file, System.IO.Path.GetFileName(file));
}
}
}
}
oZipStream.Finish();
oZipStream.Close();
oZipStream.Dispose();
oZipStream = null;
oZipEntry = null;
ostream = null;
ar.Clear();
ar = null;
}
private static ArrayList GenerateFileList(string Dir)

View File

@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Web;
using ICSharpCode.SharpZipLib.Zip;
using umbraco;
namespace umbraco.cms.businesslogic.utilities
@@ -12,47 +12,13 @@ namespace umbraco.cms.businesslogic.utilities
{
public static void UnPack(string ZipFilePath, string UnPackDirectory, bool DeleteZipFile)
{
// Unzip
string tempDir = UnPackDirectory;
Directory.CreateDirectory(tempDir);
ZipInputStream s = new ZipInputStream(File.OpenRead(ZipFilePath));
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
if (Directory.Exists(UnPackDirectory) != true)
{
string directoryName = Path.GetDirectoryName(theEntry.Name);
string fileName = Path.GetFileName(theEntry.Name);
if (fileName != String.Empty)
{
FileStream streamWriter = File.Create(tempDir + Path.DirectorySeparatorChar + fileName);
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = s.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
// Clean up
s.Close();
Directory.CreateDirectory(UnPackDirectory);
}
if (DeleteZipFile)
File.Delete(ZipFilePath);
}
}

View File

@@ -129,6 +129,8 @@
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Security">
<Name>System.Security</Name>
</Reference>