Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/04/14 12:56:57 (9 years ago)
Author:
ascheibe
Message:

#2247 switched persistence, instance providers, plugin infrastructure and MathJax to System.IO.Compression

Location:
trunk/sources/HeuristicLab.PluginInfrastructure/3.3
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Advanced/InstallationManager.cs

    r11171 r11650  
    2323using System.Collections.Generic;
    2424using System.IO;
     25using System.IO.Compression;
    2526using System.Linq;
    2627using System.ServiceModel;
    2728using HeuristicLab.PluginInfrastructure.Manager;
    28 using ICSharpCode.SharpZipLib.Zip;
    2929
    3030namespace HeuristicLab.PluginInfrastructure.Advanced {
     
    183183
    184184    private void Unpack(byte[] zippedPackage) {
    185       using (ZipInputStream s = new ZipInputStream(new MemoryStream(zippedPackage))) {
    186         ZipEntry theEntry;
    187         while ((theEntry = s.GetNextEntry()) != null) {
    188           string directoryName = pluginDir;
    189           string fileName = Path.GetFileName(theEntry.Name);
    190           // create directory
    191           if (!string.IsNullOrEmpty(directoryName)) {
    192             Directory.CreateDirectory(directoryName);
    193           }
    194           if (!string.IsNullOrEmpty(fileName)) {
    195             string fullPath = Path.Combine(directoryName, fileName);
    196             string fullDirPath = Path.GetDirectoryName(fullPath);
    197             if (!Directory.Exists(fullDirPath)) Directory.CreateDirectory(fullDirPath);
    198             using (FileStream streamWriter = File.Create(fullPath)) {
    199               int size = 2048;
    200               byte[] data = new byte[2048];
    201               while (true) {
    202                 size = s.Read(data, 0, data.Length);
    203                 if (size > 0) {
    204                   streamWriter.Write(data, 0, size);
    205                 } else {
    206                   break;
     185      using (MemoryStream memStream = new MemoryStream(zippedPackage)) {
     186        using (ZipArchive zip = new ZipArchive(memStream, ZipArchiveMode.Read)) {
     187          foreach (var theEntry in zip.Entries) {
     188            string directoryName = pluginDir;
     189            string fileName = Path.GetFileName(theEntry.Name);
     190            // create directory
     191            if (!string.IsNullOrEmpty(directoryName)) {
     192              Directory.CreateDirectory(directoryName);
     193            }
     194            if (!string.IsNullOrEmpty(fileName)) {
     195              string fullPath = Path.Combine(directoryName, fileName);
     196              string fullDirPath = Path.GetDirectoryName(fullPath);
     197              if (!Directory.Exists(fullDirPath)) Directory.CreateDirectory(fullDirPath);
     198              using (FileStream streamWriter = File.Create(fullPath)) {
     199                int size = 2048;
     200                byte[] data = new byte[2048];
     201
     202                using (BinaryReader reader = new BinaryReader(theEntry.Open())) {
     203                  while (true) {
     204                    size = reader.Read(data, 0, data.Length);
     205                    if (size > 0) {
     206                      streamWriter.Write(data, 0, size);
     207                    } else {
     208                      break;
     209                    }
     210                  }
    207211                }
     212                streamWriter.Close();
    208213              }
    209               streamWriter.Close();
    210214            }
    211215          }
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Advanced/UploadPluginsView.cs

    r11171 r11650  
    2525using System.Drawing;
    2626using System.IO;
     27using System.IO.Compression;
    2728using System.Linq;
    2829using System.ServiceModel;
    2930using System.Windows.Forms;
    3031using HeuristicLab.PluginInfrastructure.Manager;
    31 using ICSharpCode.SharpZipLib.Zip;
    3232
    3333namespace HeuristicLab.PluginInfrastructure.Advanced {
     
    262262    private static byte[] CreateZipPackage(IPluginDescription plugin) {
    263263      using (MemoryStream stream = new MemoryStream()) {
    264         ZipFile zipFile = new ZipFile(stream);
    265         zipFile.BeginUpdate();
     264        ZipArchive zipFile = new ZipArchive(stream, ZipArchiveMode.Create);
    266265        foreach (var file in plugin.Files) {
    267           zipFile.Add(file.Name);
    268         }
    269         zipFile.CommitUpdate();
     266          zipFile.CreateEntry(file.Name);
     267        }
    270268        stream.Seek(0, SeekOrigin.Begin);
    271269        return stream.GetBuffer();
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/HeuristicLab.PluginInfrastructure-3.3.csproj

    r11623 r11650  
    114114    <Reference Include="System.Drawing" />
    115115    <Reference Include="System.IdentityModel" />
     116    <Reference Include="System.IO.Compression" />
    116117    <Reference Include="System.Runtime.Serialization" />
    117118    <Reference Include="System.ServiceModel" />
    118119    <Reference Include="System.Windows.Forms" />
    119120    <Reference Include="System.Xml" />
    120     <Reference Include="ICSharpCode.SharpZipLib">
    121       <HintPath>ICSharpCode.SharpZipLib.dll</HintPath>
    122     </Reference>
    123121  </ItemGroup>
    124122  <ItemGroup>
     
    316314  </ItemGroup>
    317315  <ItemGroup>
    318     <Content Include="ICSharpCode.SharpZipLib License.txt">
    319       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    320     </Content>
    321     <Content Include="ICSharpCode.SharpZipLib.dll">
    322       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    323     </Content>
    324316    <EmbeddedResource Include="Advanced\DeploymentService\services.heuristiclab.com.cer" />
    325317    <None Include="Resources\Error.ico" />
Note: See TracChangeset for help on using the changeset viewer.