Skip to content

Commit d9a25e1

Browse files
committed
Cleanup of Samples, Part 3
* Change iCSharpCode.SharpZipLib.dll from Reference to ProjectReference * Fix Cmd_Checksum to use the correct filename
1 parent 4a054b3 commit d9a25e1

35 files changed

Lines changed: 734 additions & 654 deletions

ICSharpCode.SharpZipLib.Samples/Samples.sln

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sz", "cs\sz\sz.csproj", "{C
4141
EndProject
4242
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "zf", "cs\zf\zf.csproj", "{90E83588-261C-45A3-964F-4B707357D437}"
4343
EndProject
44-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "unzipfile", "cs\unzipfile\unzipfile.csproj", "{DE6AA83B-1EFA-41B0-85D9-49DA1B0202BC}"
44+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnZipFile", "cs\unzipfile\UnZipFile.csproj", "{DE6AA83B-1EFA-41B0-85D9-49DA1B0202BC}"
4545
EndProject
46-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "viewzipfile", "cs\viewzipfile\viewzipfile.csproj", "{F356B460-0DEA-4F7D-9CD8-7475B9BEC1F7}"
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewZipFile", "cs\viewzipfile\ViewZipFile.csproj", "{F356B460-0DEA-4F7D-9CD8-7475B9BEC1F7}"
4747
EndProject
4848
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cmd_BZip2", "cs\Cmd_BZip2\Cmd_BZip2.csproj", "{7520CE0B-F1D4-4148-8427-BB03669D7672}"
4949
EndProject
@@ -82,7 +82,9 @@ Global
8282
{2B42AA12-DD23-4EB8-A1CD-5D0F4B772895}.Release|Any CPU.ActiveCfg = Release|Any CPU
8383
{2B42AA12-DD23-4EB8-A1CD-5D0F4B772895}.Release|Any CPU.Build.0 = Release|Any CPU
8484
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85+
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
8586
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
87+
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Any CPU.Build.0 = Release|Any CPU
8688
{CE304F35-FABF-4A24-AC48-5710670A82BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
8789
{CE304F35-FABF-4A24-AC48-5710670A82BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
8890
{CE304F35-FABF-4A24-AC48-5710670A82BE}.Release|Any CPU.ActiveCfg = Release|Any CPU

ICSharpCode.SharpZipLib.Samples/cs/Cmd_BZip2/Cmd_BZip2.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ copy Cmd_BZip2.exe bunzip2.exe</PostBuildEvent>
7979
</PropertyGroup>
8080
<ItemGroup>
8181
<Reference Include="System" />
82-
<Reference Include="ICSharpCode.SharpZipLib">
83-
<HintPath>..\..\..\bin\Release\ICSharpCode.SharpZipLib.dll</HintPath>
84-
<Private>True</Private>
85-
</Reference>
8682
</ItemGroup>
8783
<ItemGroup>
8884
<Compile Include="..\..\..\GlobalAssemblyInfo.cs">
@@ -104,5 +100,11 @@ copy Cmd_BZip2.exe bunzip2.exe</PostBuildEvent>
104100
<ItemGroup>
105101
<Content Include="readme.txt" />
106102
</ItemGroup>
103+
<ItemGroup>
104+
<ProjectReference Include="..\..\..\ICSharpCode.SharpZipLib\ICSharpCode.SharpZipLib.csproj">
105+
<Project>{0e7413ff-eb9e-4714-acf2-be3a6a7b2ffd}</Project>
106+
<Name>ICSharpCode.SharpZipLib</Name>
107+
</ProjectReference>
108+
</ItemGroup>
107109
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
108110
</Project>

ICSharpCode.SharpZipLib.Samples/cs/Cmd_Checksum/Cmd_Checksum.cs

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030

3131
using ICSharpCode.SharpZipLib.Checksum;
3232

33-
class Cmd_Crc
33+
class Cmd_Checksum
3434
{
3535
static void ShowHelp()
3636
{
3737
Console.Error.WriteLine("Compress or uncompress FILEs (by default, compress FILES in-place).");
3838
Console.Error.WriteLine("Version {0} using SharpZipLib {1}",
39-
typeof(Cmd_Crc).Assembly.GetName().Version,
39+
typeof(Cmd_Checksum).Assembly.GetName().Version,
4040
typeof(IChecksum).Assembly.GetName().Version);
4141
Console.Error.WriteLine("");
4242
Console.Error.WriteLine("Mandatory arguments to long options are mandatory for short options too.");
@@ -48,6 +48,11 @@ static void ShowHelp()
4848
Console.Error.WriteLine(" -9, --best compress better");
4949
}
5050

51+
#region Instance Fields
52+
private static Command command_ = Command.Nothing;
53+
private static string file_;
54+
#endregion
55+
5156
#region Command parsing
5257
enum Command
5358
{
@@ -65,36 +70,36 @@ public ArgumentParser(string[] args)
6570
{
6671
foreach (string argument in args) {
6772
switch (argument) {
68-
case "-?": // for backwards compatibility
69-
case "-h":
70-
case "--help":
71-
SetCommand(Command.Help);
72-
break;
73-
case "--adler32":
74-
SetCommand(Command.Adler);
75-
break;
76-
case "--bzip2":
77-
SetCommand(Command.BZip2);
78-
break;
79-
case "--crc32":
80-
SetCommand(Command.Crc32);
81-
break;
82-
default:
83-
if (argument[0] == '-') {
84-
Console.Error.WriteLine("Unknown argument {0}", argument);
85-
command_ = Command.Stop;
86-
} else if (file_ == null) {
87-
file_ = argument;
88-
89-
if (!System.IO.File.Exists(file_)) {
90-
Console.Error.WriteLine("File not found '{0}'", file_);
73+
case "-?": // for backwards compatibility
74+
case "-h":
75+
case "--help":
76+
SetCommand(Command.Help);
77+
break;
78+
case "--adler32":
79+
SetCommand(Command.Adler);
80+
break;
81+
case "--bzip2":
82+
SetCommand(Command.BZip2);
83+
break;
84+
case "--crc32":
85+
SetCommand(Command.Crc32);
86+
break;
87+
default:
88+
if (argument[0] == '-') {
89+
Console.Error.WriteLine("Unknown argument {0}", argument);
90+
command_ = Command.Stop;
91+
} else if (file_ == null) {
92+
file_ = argument;
93+
94+
if (!System.IO.File.Exists(file_)) {
95+
Console.Error.WriteLine("File not found '{0}'", file_);
96+
command_ = Command.Stop;
97+
}
98+
} else {
99+
Console.Error.WriteLine("File has already been specified");
91100
command_ = Command.Stop;
92101
}
93-
} else {
94-
Console.Error.WriteLine("File has already been specified");
95-
command_ = Command.Stop;
96-
}
97-
break;
102+
break;
98103
}
99104
}
100105

@@ -117,63 +122,64 @@ void SetCommand(Command command)
117122
}
118123
}
119124

120-
public string Source
121-
{
125+
public string Source {
122126
get { return file_; }
123127
}
124128

125-
public Command Command
126-
{
129+
public Command Command {
127130
get { return command_; }
128131
}
129-
130-
#region Instance Fields
131-
Command command_ = Command.Nothing;
132-
string file_;
133-
#endregion
134132
}
135133
#endregion
136134

137-
138135
public static int Main(string[] args)
139136
{
140137
if (args.Length == 0) {
141138
ShowHelp();
142139
return 1;
143140
}
144141

145-
if (!File.Exists(args[0])) {
146-
Console.Error.WriteLine("Cannot find file {0}", args[0]);
142+
var parser = new ArgumentParser(args);
143+
144+
if (!File.Exists(file_)) {
145+
Console.Error.WriteLine("Cannot find file {0}", file_);
147146
ShowHelp();
148147
return 1;
149148
}
150149

151-
var parser = new ArgumentParser(args);
152-
153-
using (FileStream checksumStream = File.OpenRead(args[0])) {
150+
using (FileStream checksumStream = File.OpenRead(file_)) {
154151

155152
byte[] buffer = new byte[4096];
156153
int bytesRead;
157154

158155
switch (parser.Command) {
159-
case Command.Help:
160-
ShowHelp();
161-
break;
162-
163-
case Command.Crc32:
164-
var currentCrc = new Crc32();
165-
while ((bytesRead = checksumStream.Read(buffer, 0, buffer.Length)) > 0) {
166-
currentCrc.Update(buffer, 0, bytesRead);
167-
}
168-
Console.WriteLine("CRC32 for {0} is 0x{1:X2}", args[0], currentCrc.Value);
169-
break;
156+
case Command.Help:
157+
ShowHelp();
158+
break;
170159

171-
case Command.Adler:
172-
var currentAdler = new Adler32();
173-
while ((bytesRead = checksumStream.Read(buffer, 0, buffer.Length)) > 0) {
174-
currentAdler.Update(buffer, 0, bytesRead);
175-
}
176-
break;
160+
case Command.Crc32:
161+
var currentCrc = new Crc32();
162+
while ((bytesRead = checksumStream.Read(buffer, 0, buffer.Length)) > 0) {
163+
currentCrc.Update(buffer, 0, bytesRead);
164+
}
165+
Console.WriteLine("CRC32 for {0} is 0x{1:X8}", args[0], currentCrc.Value);
166+
break;
167+
168+
case Command.BZip2:
169+
var currentBZip2Crc = new BZip2Crc();
170+
while ((bytesRead = checksumStream.Read(buffer, 0, buffer.Length)) > 0) {
171+
currentBZip2Crc.Update(buffer, 0, bytesRead);
172+
}
173+
Console.WriteLine("BZip2CRC32 for {0} is 0x{1:X8}", args[0], currentBZip2Crc.Value);
174+
break;
175+
176+
case Command.Adler:
177+
var currentAdler = new Adler32();
178+
while ((bytesRead = checksumStream.Read(buffer, 0, buffer.Length)) > 0) {
179+
currentAdler.Update(buffer, 0, bytesRead);
180+
}
181+
Console.WriteLine("Adler32 for {0} is 0x{1:X8}", args[0], currentAdler.Value);
182+
break;
177183
}
178184
}
179185
return 0;

ICSharpCode.SharpZipLib.Samples/cs/Cmd_Checksum/Cmd_Checksum.csproj

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
<SchemaVersion>2.0</SchemaVersion>
77
<ProjectGuid>{82724A84-3399-4C27-91D2-2B2629B9E3F6}</ProjectGuid>
88
<RootNamespace>ICSharpCode.SharpZipLib.Samples</RootNamespace>
9-
<AssemblyName>Cmd_Crc</AssemblyName>
9+
<AssemblyName>Cmd_Checksum</AssemblyName>
1010
<OutputType>Exe</OutputType>
1111
<ApplicationIcon />
1212
<WarningLevel>4</WarningLevel>
1313
<NoWarn />
14-
<StartupObject>Cmd_Crc</StartupObject>
14+
<StartupObject>Cmd_Checksum</StartupObject>
1515
<NoStdLib>False</NoStdLib>
1616
<NoConfig>False</NoConfig>
1717
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
1818
<PreBuildEvent />
19-
<PostBuildEvent>copy Cmd_GZip.exe gzip.exe
20-
copy Cmd_GZip.exe gunzip.exe</PostBuildEvent>
19+
<PostBuildEvent>
20+
</PostBuildEvent>
2121
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
2222
<FileUpgradeFlags>
2323
</FileUpgradeFlags>
@@ -65,18 +65,14 @@ copy Cmd_GZip.exe gunzip.exe</PostBuildEvent>
6565
<OutputPath>..\bin\</OutputPath>
6666
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
6767
<Prefer32Bit>false</Prefer32Bit>
68-
<DocumentationFile>..\bin\Cmd_Crc.xml</DocumentationFile>
68+
<DocumentationFile>..\bin\Cmd_Checksum.xml</DocumentationFile>
6969
<ErrorReport>prompt</ErrorReport>
7070
<FileAlignment>2048</FileAlignment>
7171
<DebugType>pdbonly</DebugType>
7272
<RunCodeAnalysis>true</RunCodeAnalysis>
7373
</PropertyGroup>
7474
<ItemGroup>
7575
<Reference Include="System" />
76-
<Reference Include="ICSharpCode.SharpZipLib">
77-
<HintPath>..\..\..\bin\Release\ICSharpCode.SharpZipLib.dll</HintPath>
78-
<Private>True</Private>
79-
</Reference>
8076
</ItemGroup>
8177
<ItemGroup>
8278
<Compile Include="..\..\..\GlobalAssemblyInfo.cs">
@@ -98,5 +94,11 @@ copy Cmd_GZip.exe gunzip.exe</PostBuildEvent>
9894
<ItemGroup>
9995
<Content Include="readme.txt" />
10096
</ItemGroup>
97+
<ItemGroup>
98+
<ProjectReference Include="..\..\..\ICSharpCode.SharpZipLib\ICSharpCode.SharpZipLib.csproj">
99+
<Project>{0e7413ff-eb9e-4714-acf2-be3a6a7b2ffd}</Project>
100+
<Name>ICSharpCode.SharpZipLib</Name>
101+
</ProjectReference>
102+
</ItemGroup>
101103
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
102104
</Project>

ICSharpCode.SharpZipLib.Samples/cs/Cmd_GZip/Cmd_GZip.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ copy Cmd_GZip.exe gunzip.exe</PostBuildEvent>
7373
</PropertyGroup>
7474
<ItemGroup>
7575
<Reference Include="System" />
76-
<Reference Include="ICSharpCode.SharpZipLib">
77-
<HintPath>..\..\..\bin\Release\ICSharpCode.SharpZipLib.dll</HintPath>
78-
<Private>True</Private>
79-
</Reference>
8076
</ItemGroup>
8177
<ItemGroup>
8278
<Compile Include="..\..\..\GlobalAssemblyInfo.cs">
@@ -98,5 +94,11 @@ copy Cmd_GZip.exe gunzip.exe</PostBuildEvent>
9894
<ItemGroup>
9995
<Content Include="readme.txt" />
10096
</ItemGroup>
97+
<ItemGroup>
98+
<ProjectReference Include="..\..\..\ICSharpCode.SharpZipLib\ICSharpCode.SharpZipLib.csproj">
99+
<Project>{0e7413ff-eb9e-4714-acf2-be3a6a7b2ffd}</Project>
100+
<Name>ICSharpCode.SharpZipLib</Name>
101+
</ProjectReference>
102+
</ItemGroup>
101103
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
102104
</Project>

ICSharpCode.SharpZipLib.Samples/cs/Cmd_ZipInfo/Cmd_ZipInfo.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@
7272
</PropertyGroup>
7373
<ItemGroup>
7474
<Reference Include="System" />
75-
<Reference Include="ICSharpCode.SharpZipLib">
76-
<HintPath>..\..\..\bin\Release\ICSharpCode.SharpZipLib.dll</HintPath>
77-
<Private>True</Private>
78-
</Reference>
7975
</ItemGroup>
8076
<ItemGroup>
8177
<Compile Include="..\..\..\GlobalAssemblyInfo.cs">
@@ -97,5 +93,11 @@
9793
<ItemGroup>
9894
<Content Include="readme.txt" />
9995
</ItemGroup>
96+
<ItemGroup>
97+
<ProjectReference Include="..\..\..\ICSharpCode.SharpZipLib\ICSharpCode.SharpZipLib.csproj">
98+
<Project>{0e7413ff-eb9e-4714-acf2-be3a6a7b2ffd}</Project>
99+
<Name>ICSharpCode.SharpZipLib</Name>
100+
</ProjectReference>
101+
</ItemGroup>
100102
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
101103
</Project>

ICSharpCode.SharpZipLib.Samples/cs/CreateZipFile/AssemblyInfo.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,8 @@
22

33
[assembly: AssemblyTitle("CreateZipFile")]
44
[assembly: AssemblyDescription("Free C# IDE")]
5-
[assembly: AssemblyConfiguration("")]
6-
[assembly: AssemblyCompany("")]
7-
[assembly: AssemblyProduct("A SharpDevelop sample")]
8-
[assembly: AssemblyCopyright("Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team")]
9-
[assembly: AssemblyTrademark("")]
105
[assembly: AssemblyCulture("")]
116

12-
[assembly: AssemblyVersion("0.85.4.369")]
13-
147
[assembly: AssemblyDelaySign(false)]
158
[assembly: AssemblyKeyFile("")]
169
[assembly: AssemblyKeyName("")]

0 commit comments

Comments
 (0)