Skip to content

Commit ed48911

Browse files
committed
Delegates renamed which is a breaking change. Other minor tweaks in ZipExtraData to allow reading of various tagged data values. Not completely finished yet.
1 parent 7bcc206 commit ed48911

File tree

9 files changed

+756
-81
lines changed

9 files changed

+756
-81
lines changed

src/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
[assembly: AssemblyCopyright("Copyright 2001-2007 Mike Krueger, John Reilly")]
7474
[assembly: AssemblyTrademark("Copyright 2001-2007 Mike Krueger, John Reilly")]
7575

76-
[assembly: AssemblyVersion("0.85.2.329")]
77-
[assembly: AssemblyInformationalVersionAttribute("0.85.2")]
76+
[assembly: AssemblyVersion("0.85.3.346")]
77+
[assembly: AssemblyInformationalVersionAttribute("0.85.3")]
7878

7979

8080
[assembly: CLSCompliant(true)]

src/Core/FileSystemScanner.cs

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public string Name
6464
get { return name_; }
6565
}
6666

67-
6867
/// <summary>
6968
/// Get set a value indicating if scanning should continue or not.
7069
/// </summary>
@@ -163,26 +162,32 @@ public bool ContinueRunning
163162
}
164163

165164
#endregion
165+
166166
#region Delegates
167167
/// <summary>
168-
/// Delegate invoked when a directory is processed.
168+
/// Delegate invoked before starting to process a directory.
169169
/// </summary>
170-
public delegate void ProcessDirectoryDelegate(object sender, DirectoryEventArgs e);
170+
public delegate void ProcessDirectoryHandler(object sender, DirectoryEventArgs e);
171171

172172
/// <summary>
173-
/// Delegate invoked when a file is processed.
173+
/// Delegate invoked before starting to process a file.
174+
/// </summary>
175+
public delegate void ProcessFileHandler(object sender, ScanEventArgs e);
176+
177+
/// <summary>
178+
/// Delegate invoked when a file has been completely processed.
174179
/// </summary>
175-
public delegate void ProcessFileDelegate(object sender, ScanEventArgs e);
180+
public delegate void CompletedFileHandler(object sender, ScanEventArgs e);
176181

177182
/// <summary>
178183
/// Delegate invoked when a directory failure is detected.
179184
/// </summary>
180-
public delegate void DirectoryFailureDelegate(object sender, ScanFailureEventArgs e);
185+
public delegate void DirectoryFailureHandler(object sender, ScanFailureEventArgs e);
181186

182187
/// <summary>
183188
/// Delegate invoked when a file failure is detected.
184189
/// </summary>
185-
public delegate void FileFailureDelegate(object sender, ScanFailureEventArgs e);
190+
public delegate void FileFailureHandler(object sender, ScanFailureEventArgs e);
186191
#endregion
187192

188193
/// <summary>
@@ -231,26 +236,32 @@ public FileSystemScanner(IScanFilter fileFilter, IScanFilter directoryFilter)
231236
directoryFilter_ = directoryFilter;
232237
}
233238
#endregion
239+
234240
#region Delegates
235241
/// <summary>
236242
/// Delegate to invoke when a directory is processed.
237243
/// </summary>
238-
public ProcessDirectoryDelegate ProcessDirectory;
244+
public ProcessDirectoryHandler ProcessDirectory;
239245

240246
/// <summary>
241247
/// Delegate to invoke when a file is processed.
242248
/// </summary>
243-
public ProcessFileDelegate ProcessFile;
249+
public ProcessFileHandler ProcessFile;
250+
251+
/// <summary>
252+
/// Delegate to invoke when processing for a file has finished.
253+
/// </summary>
254+
public CompletedFileHandler CompletedFile;
244255

245256
/// <summary>
246257
/// Delegate to invoke when a directory failure is detected.
247258
/// </summary>
248-
public DirectoryFailureDelegate DirectoryFailure;
259+
public DirectoryFailureHandler DirectoryFailure;
249260

250261
/// <summary>
251262
/// Delegate to invoke when a file failure is detected.
252263
/// </summary>
253-
public FileFailureDelegate FileFailure;
264+
public FileFailureHandler FileFailure;
254265
#endregion
255266

256267
/// <summary>
@@ -289,21 +300,31 @@ public void OnFileFailure(string file, Exception e)
289300
/// Raise the ProcessFile event.
290301
/// </summary>
291302
/// <param name="file">The file name.</param>
292-
public void OnProcessFile(string file)
303+
void OnProcessFile(string file)
293304
{
294305
if ( ProcessFile != null ) {
295306
ScanEventArgs args = new ScanEventArgs(file);
296307
ProcessFile(this, args);
297308
alive_ = args.ContinueRunning;
298309
}
299310
}
300-
311+
312+
void OnCompleteFile(string file)
313+
{
314+
if (CompletedFile != null)
315+
{
316+
ScanEventArgs args = new ScanEventArgs(file);
317+
CompletedFile(this, args);
318+
alive_ = args.ContinueRunning;
319+
}
320+
}
321+
301322
/// <summary>
302323
/// Raise the ProcessDirectory event.
303324
/// </summary>
304325
/// <param name="directory">The directory name.</param>
305326
/// <param name="hasMatchingFiles">Flag indicating if the directory has matching files.</param>
306-
public void OnProcessDirectory(string directory, bool hasMatchingFiles)
327+
void OnProcessDirectory(string directory, bool hasMatchingFiles)
307328
{
308329
if ( ProcessDirectory != null ) {
309330
DirectoryEventArgs args = new DirectoryEventArgs(directory, hasMatchingFiles);

src/ICSharpCode.SharpZLib.csproj

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
44
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
55
<SchemaVersion>2.0</SchemaVersion>
6-
<ProjectGuid>{0AAD2BF5-F6C9-4180-9C50-9200726052DD}</ProjectGuid>
6+
<ProjectGuid>{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}</ProjectGuid>
77
<RootNamespace>ICSharpCode.SharpZipLib</RootNamespace>
88
<AssemblyName>ICSharpCode.SharpZipLib</AssemblyName>
99
<OutputType>Library</OutputType>
@@ -12,26 +12,27 @@
1212
<StartupObject />
1313
<NoStdLib>False</NoStdLib>
1414
<NoConfig>False</NoConfig>
15-
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
15+
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
1616
<PreBuildEvent />
1717
<PostBuildEvent />
18+
<DocumentationFile>..\bin\ICSharpCode.SharpZipLib.xml</DocumentationFile>
1819
</PropertyGroup>
1920
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
20-
<DebugSymbols>False</DebugSymbols>
21+
<DebugSymbols>false</DebugSymbols>
2122
<Optimize>True</Optimize>
2223
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
2324
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
24-
<DefineConstants>NET_VER_1</DefineConstants>
2525
<OutputPath>..\bin\</OutputPath>
26-
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
26+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
27+
<DebugType>None</DebugType>
2728
</PropertyGroup>
2829
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2930
<DebugSymbols>true</DebugSymbols>
3031
<Optimize>False</Optimize>
3132
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
3233
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
3334
<OutputPath>..\bin\</OutputPath>
34-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
35+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
3536
<DebugType>Full</DebugType>
3637
</PropertyGroup>
3738
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
@@ -41,9 +42,6 @@
4142
<PlatformTarget>AnyCPU</PlatformTarget>
4243
<FileAlignment>4096</FileAlignment>
4344
</PropertyGroup>
44-
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
45-
<StartAction>Project</StartAction>
46-
</PropertyGroup>
4745
<ItemGroup>
4846
<Reference Include="System" />
4947
<Reference Include="System.Data" />
@@ -62,8 +60,8 @@
6260
<Compile Include="Zip\ZipOutputStream.cs" />
6361
<Compile Include="Zip\ZipConstants.cs" />
6462
<Compile Include="Zip\ZipFile.cs" />
65-
<Compile Include="GZip\GZipOutputStream.cs" />
66-
<Compile Include="GZip\GZipInputStream.cs" />
63+
<Compile Include="GZip\GzipOutputStream.cs" />
64+
<Compile Include="GZip\GzipInputStream.cs" />
6765
<Compile Include="GZip\GZipConstants.cs" />
6866
<Compile Include="Zip\ZipException.cs" />
6967
<Compile Include="BZip2\BZip2InputStream.cs" />
@@ -109,13 +107,6 @@
109107
<Compile Include="Zip\ZipEntryFactory.cs" />
110108
<Compile Include="Zip\IEntryFactory.cs" />
111109
</ItemGroup>
112-
<ItemGroup>
113-
<Folder Include="Tar\" />
114-
<Folder Include="Zip\Compression\" />
115-
<Folder Include="Zip\Compression\Streams\" />
116-
<Folder Include="Core\" />
117-
<Folder Include="Encryption\" />
118-
</ItemGroup>
119110
<ItemGroup />
120111
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
121112
</Project>

src/Zip/FastZip.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,27 @@ public class FastZipEvents
4747
/// <summary>
4848
/// Delegate to invoke when processing directories.
4949
/// </summary>
50-
public ProcessDirectoryDelegate ProcessDirectory;
50+
public ProcessDirectoryHandler ProcessDirectory;
5151

5252
/// <summary>
5353
/// Delegate to invoke when processing files.
5454
/// </summary>
55-
public ProcessFileDelegate ProcessFile;
55+
public ProcessFileHandler ProcessFile;
56+
57+
/// <summary>
58+
/// Delegate to invoke when processing for a file has been completed.
59+
/// </summary>
60+
public CompletedFileHandler CompletedFile;
5661

5762
/// <summary>
5863
/// Delegate to invoke when processing directory failures.
5964
/// </summary>
60-
public DirectoryFailureDelegate DirectoryFailure;
65+
public DirectoryFailureHandler DirectoryFailure;
6166

6267
/// <summary>
6368
/// Delegate to invoke when processing file failures.
6469
/// </summary>
65-
public FileFailureDelegate FileFailure;
70+
public FileFailureHandler FileFailure;
6671

6772
/// <summary>
6873
/// Raise the <see cref="DirectoryFailure">directory failure</see> event.
@@ -99,7 +104,7 @@ public bool OnFileFailure(string file, Exception e)
99104
}
100105

101106
/// <summary>
102-
/// Raises the <see cref="ProcessFile">Process File delegate</see>.
107+
/// Fires the <see cref="ProcessFile">Process File delegate</see>.
103108
/// </summary>
104109
/// <param name="file">The file being processed.</param>
105110
/// <returns>A boolean indicating if execution should continue or not.</returns>
@@ -114,6 +119,22 @@ public bool OnProcessFile(string file)
114119
return result;
115120
}
116121

122+
/// <summary>
123+
/// Fires the CompletedFile delegate
124+
/// </summary>
125+
/// <param name="file">The file whose processing has been completed.</param>
126+
/// <returns>A boolean indicating if execution should continue or not.</returns>
127+
public bool OnCompletedFile(string file)
128+
{
129+
bool result = true;
130+
if ( CompletedFile != null ) {
131+
ScanEventArgs args = new ScanEventArgs(file);
132+
CompletedFile(this, args);
133+
result = args.ContinueRunning;
134+
}
135+
return result;
136+
}
137+
117138
/// <summary>
118139
/// Fires the <see cref="ProcessDirectory">process directory</see> delegate.
119140
/// </summary>
@@ -306,9 +327,9 @@ public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse,
306327
#endif
307328

308329
FileSystemScanner scanner = new FileSystemScanner(fileFilter, directoryFilter);
309-
scanner.ProcessFile += new ProcessFileDelegate(ProcessFile);
330+
scanner.ProcessFile += new ProcessFileHandler(ProcessFile);
310331
if ( this.CreateEmptyDirectories ) {
311-
scanner.ProcessDirectory += new ProcessDirectoryDelegate(ProcessDirectory);
332+
scanner.ProcessDirectory += new ProcessDirectoryHandler(ProcessDirectory);
312333
}
313334

314335
if (events_ != null) {
@@ -461,7 +482,12 @@ void ExtractFileEntry(ZipEntry entry, string targetName)
461482
if ( buffer_ == null ) {
462483
buffer_ = new byte[4096];
463484
}
485+
464486
StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_);
487+
488+
if (events_ != null) {
489+
continueRunning_ = events_.OnCompletedFile(entry.Name);
490+
}
465491
}
466492

467493
#if !NETCF_1_0 && !NETCF_2_0

src/Zip/ZipEntry.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ public int HostSystem
540540
/// 6.3 - File is encrypted using Blowfish<br/>
541541
/// 6.3 - File is encrypted using Twofish<br/>
542542
/// </remarks>
543+
/// <seealso cref="CanDecompress"></seealso>
543544
public int Version
544545
{
545546
get {
@@ -572,6 +573,8 @@ public int Version
572573
/// <summary>
573574
/// Get a value indicating wether this entry can be decompressed by the library.
574575
/// </summary>
576+
/// <remarks>This is based on the <see cref="Version"></see> and
577+
/// wether the <see cref="IsCompressionMethodSupported()">compression method</see> is supported.</remarks>
575578
public bool CanDecompress
576579
{
577580
get {

src/Zip/ZipEntryFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public ZipEntry MakeFileEntry(string fileName)
212212
}
213213

214214
/// <summary>
215-
/// Make a new <see cref="ZipEntry"/> for a file.
215+
/// Make a new <see cref="ZipEntry"/> from a name.
216216
/// </summary>
217217
/// <param name="fileName">The name of the file to create a new entry for.</param>
218218
/// <param name="useFileSystem">If true entry detail is retrieved from the file system if the file exists.</param>
@@ -231,7 +231,7 @@ public ZipEntry MakeFileEntry(string fileName, bool useFileSystem)
231231
fi = new FileInfo(fileName);
232232
}
233233

234-
if (useFileSystem && fi.Exists)
234+
if ((fi != null) && fi.Exists)
235235
{
236236
switch (timeSetting_)
237237
{
@@ -333,7 +333,7 @@ public ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem)
333333
}
334334

335335

336-
if (useFileSystem && di.Exists)
336+
if ((di != null) && di.Exists)
337337
{
338338
switch (timeSetting_)
339339
{

0 commit comments

Comments
 (0)