- Timestamp:
- 12/04/14 12:56:57 (10 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPInstanceProvider.cs
r11171 r11650 23 23 using System.Collections.Generic; 24 24 using System.IO; 25 using System.IO.Compression; 25 26 using System.Linq; 26 27 using System.Reflection; 27 28 using System.Text.RegularExpressions; 28 using ICSharpCode.SharpZipLib.Zip;29 29 30 30 namespace HeuristicLab.Problems.Instances.ElloumiCTAP { … … 56 56 var solutionsArchiveName = GetResourceName(FileName + @"\.sol\.zip"); 57 57 if (!String.IsNullOrEmpty(solutionsArchiveName)) { 58 using (var solutionsZipFile = new Zip InputStream(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) {59 foreach (var entry in GetZipContents(solutionsZipFile))60 solutions.Add(Path.GetFileNameWithoutExtension(entry ) + ".dat", entry);58 using (var solutionsZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName), ZipArchiveMode.Read)) { 59 foreach (var entry in solutionsZipFile.Entries) 60 solutions.Add(Path.GetFileNameWithoutExtension(entry.Name) + ".dat", entry.Name); 61 61 } 62 62 } … … 64 64 if (String.IsNullOrEmpty(instanceArchiveName)) yield break; 65 65 66 using (var instanceStream = new Zip InputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {67 foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) {66 using (var instanceStream = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName), ZipArchiveMode.Read)) { 67 foreach (var entry in instanceStream.Entries.Select(x => x.Name).OrderBy(x => x)) { 68 68 yield return new ElloumiCTAPDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetDescription(), entry, solutions.ContainsKey(entry) ? solutions[entry] : String.Empty); 69 69 } … … 74 74 var descriptor = (ElloumiCTAPDataDescriptor)id; 75 75 var instanceArchiveName = GetResourceName(FileName + @"\.dat\.zip"); 76 using (var instancesZipFile = new Zip File(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {76 using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName), ZipArchiveMode.Read)) { 77 77 var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier); 78 using (var stream = instancesZipFile.GetInputStream(entry)) {78 using (var stream = entry.Open()) { 79 79 var parser = new ElloumiCTAPParser(); 80 80 parser.Parse(stream); … … 86 86 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { 87 87 var solutionsArchiveName = GetResourceName(FileName + @"\.sol\.zip"); 88 using (var solutionsZipFile = new Zip File(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) {88 using (var solutionsZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName), ZipArchiveMode.Read)) { 89 89 entry = solutionsZipFile.GetEntry(descriptor.SolutionIdentifier); 90 using (var solStream = solutionsZipFile.GetInputStream(entry)) {90 using (var solStream = entry.Open()) { 91 91 ElloumiCTAPSolutionParser slnParser = new ElloumiCTAPSolutionParser(); 92 92 slnParser.Parse(solStream, instance.MemoryRequirements.Length); … … 138 138 .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success).SingleOrDefault(); 139 139 } 140 141 protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) {142 ZipEntry entry;143 while ((entry = zipFile.GetNextEntry()) != null) {144 yield return entry.Name;145 }146 }147 140 } 148 141 } -
trunk/sources/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/HeuristicLab.Problems.Instances.ElloumiCTAP-3.3.csproj
r11623 r11650 109 109 </PropertyGroup> 110 110 <ItemGroup> 111 <Reference Include="ICSharpCode.SharpZipLib">112 <HintPath>..\..\HeuristicLab.PluginInfrastructure\3.3\ICSharpCode.SharpZipLib.dll</HintPath>113 <Private>False</Private>114 </Reference>115 111 <Reference Include="System" /> 116 112 <Reference Include="System.Core" /> 117 113 <Reference Include="System.Data" /> 114 <Reference Include="System.IO.Compression" /> 118 115 </ItemGroup> 119 116 <ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.