remove last 3 dependencies
This commit is contained in:
@@ -5,7 +5,6 @@ using System.Globalization;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
|
||||||
using Umbraco.Core;
|
using Umbraco.Core;
|
||||||
using Umbraco.Core.Auditing;
|
using Umbraco.Core.Auditing;
|
||||||
using Umbraco.Core.IO;
|
using Umbraco.Core.IO;
|
||||||
@@ -14,6 +13,7 @@ using Umbraco.Core.Packaging;
|
|||||||
using umbraco.cms.businesslogic.web;
|
using umbraco.cms.businesslogic.web;
|
||||||
using umbraco.BusinessLogic;
|
using umbraco.BusinessLogic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO.Compression;
|
||||||
using umbraco.cms.businesslogic.template;
|
using umbraco.cms.businesslogic.template;
|
||||||
using umbraco.interfaces;
|
using umbraco.interfaces;
|
||||||
using Umbraco.Core.Events;
|
using Umbraco.Core.Events;
|
||||||
@@ -520,7 +520,7 @@ namespace umbraco.cms.businesslogic.packager
|
|||||||
/// <param name="tempDir"></param>
|
/// <param name="tempDir"></param>
|
||||||
public void InstallCleanUp(int packageId, string tempDir)
|
public void InstallCleanUp(int packageId, string tempDir)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Directory.Exists(tempDir))
|
if (Directory.Exists(tempDir))
|
||||||
{
|
{
|
||||||
Directory.Delete(tempDir, true);
|
Directory.Delete(tempDir, true);
|
||||||
@@ -751,8 +751,6 @@ namespace umbraco.cms.businesslogic.packager
|
|||||||
|
|
||||||
private static string UnPack(string zipName, bool deleteFile)
|
private static string UnPack(string zipName, bool deleteFile)
|
||||||
{
|
{
|
||||||
// Unzip
|
|
||||||
|
|
||||||
//the temp directory will be the package GUID - this keeps it consistent!
|
//the temp directory will be the package GUID - this keeps it consistent!
|
||||||
//the zipName is always the package Guid.umb
|
//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);
|
if (Directory.Exists(tempDir)) Directory.Delete(tempDir, true);
|
||||||
Directory.CreateDirectory(tempDir);
|
Directory.CreateDirectory(tempDir);
|
||||||
|
|
||||||
var s = new ZipInputStream(File.OpenRead(zipName));
|
ZipFile.ExtractToDirectory(zipName, tempDir);
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
if (deleteFile)
|
if (deleteFile)
|
||||||
{
|
{
|
||||||
File.Delete(zipName);
|
File.Delete(zipName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return tempDir;
|
return tempDir;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ using System.Web.UI.WebControls;
|
|||||||
using System.Web.UI.WebControls.WebParts;
|
using System.Web.UI.WebControls.WebParts;
|
||||||
using System.Web.UI.HtmlControls;
|
using System.Web.UI.HtmlControls;
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
using umbraco.cms.businesslogic.template;
|
using umbraco.cms.businesslogic.template;
|
||||||
using umbraco.cms.businesslogic.web;
|
using umbraco.cms.businesslogic.web;
|
||||||
using umbraco.cms.businesslogic.macro;
|
using umbraco.cms.businesslogic.macro;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
|
||||||
using Umbraco.Core;
|
using Umbraco.Core;
|
||||||
using Umbraco.Core.IO;
|
using Umbraco.Core.IO;
|
||||||
|
|
||||||
@@ -278,58 +278,24 @@ namespace umbraco.cms.businesslogic.packager
|
|||||||
/// <param name="savePath">The save path.</param>
|
/// <param name="savePath">The save path.</param>
|
||||||
public static void ZipPackage(string Path, string savePath)
|
public static void ZipPackage(string Path, string savePath)
|
||||||
{
|
{
|
||||||
string OutPath = savePath;
|
|
||||||
|
|
||||||
ArrayList ar = GenerateFileList(Path);
|
ArrayList ar = GenerateFileList(Path);
|
||||||
// generate file list
|
// generate file list
|
||||||
// find number of chars to remove from orginal file path
|
// find number of chars to remove from orginal file path
|
||||||
int TrimLength = (Directory.GetParent(Path)).ToString().Length;
|
|
||||||
|
|
||||||
TrimLength += 1;
|
using (var memoryStream = new MemoryStream())
|
||||||
|
|
||||||
//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
|
|
||||||
{
|
{
|
||||||
oZipEntry = new ZipEntry(Fil.Remove(0, TrimLength));
|
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create))
|
||||||
oZipStream.PutNextEntry(oZipEntry);
|
|
||||||
|
|
||||||
|
|
||||||
if (!Fil.EndsWith(@"/")) // if a file ends with '/' its a directory
|
|
||||||
{
|
{
|
||||||
ostream = File.OpenRead(Fil);
|
foreach (string file in ar)
|
||||||
|
{
|
||||||
obuffer = new byte[ostream.Length];
|
if (file.EndsWith(@"/") != true) // it's not a directory
|
||||||
|
{
|
||||||
// byte buffer
|
archive.CreateEntryFromFile(file, System.IO.Path.GetFileName(file));
|
||||||
ostream.Read(obuffer, 0, obuffer.Length);
|
}
|
||||||
|
}
|
||||||
oZipStream.Write(obuffer, 0, obuffer.Length);
|
|
||||||
ostream.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oZipStream.Finish();
|
|
||||||
oZipStream.Close();
|
|
||||||
oZipStream.Dispose();
|
|
||||||
oZipStream = null;
|
|
||||||
|
|
||||||
oZipEntry = null;
|
|
||||||
|
|
||||||
|
|
||||||
ostream = null;
|
|
||||||
ar.Clear();
|
|
||||||
ar = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList GenerateFileList(string Dir)
|
private static ArrayList GenerateFileList(string Dir)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
|
||||||
using umbraco;
|
using umbraco;
|
||||||
|
|
||||||
namespace umbraco.cms.businesslogic.utilities
|
namespace umbraco.cms.businesslogic.utilities
|
||||||
@@ -12,47 +12,13 @@ namespace umbraco.cms.businesslogic.utilities
|
|||||||
{
|
{
|
||||||
public static void UnPack(string ZipFilePath, string UnPackDirectory, bool DeleteZipFile)
|
public static void UnPack(string ZipFilePath, string UnPackDirectory, bool DeleteZipFile)
|
||||||
{
|
{
|
||||||
// Unzip
|
if (Directory.Exists(UnPackDirectory) != true)
|
||||||
string tempDir = UnPackDirectory;
|
|
||||||
Directory.CreateDirectory(tempDir);
|
|
||||||
|
|
||||||
ZipInputStream s = new ZipInputStream(File.OpenRead(ZipFilePath));
|
|
||||||
|
|
||||||
ZipEntry theEntry;
|
|
||||||
while ((theEntry = s.GetNextEntry()) != null)
|
|
||||||
{
|
{
|
||||||
string directoryName = Path.GetDirectoryName(theEntry.Name);
|
Directory.CreateDirectory(UnPackDirectory);
|
||||||
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();
|
|
||||||
if (DeleteZipFile)
|
if (DeleteZipFile)
|
||||||
File.Delete(ZipFilePath);
|
File.Delete(ZipFilePath);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,8 @@
|
|||||||
<Name>System.Data</Name>
|
<Name>System.Data</Name>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.IO.Compression" />
|
||||||
|
<Reference Include="System.IO.Compression.FileSystem" />
|
||||||
<Reference Include="System.Security">
|
<Reference Include="System.Security">
|
||||||
<Name>System.Security</Name>
|
<Name>System.Security</Name>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|||||||
Reference in New Issue
Block a user