diff options
author | Rob Mensching <rob@firegiant.com> | 2022-07-14 15:19:53 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-07-14 16:02:24 -0700 |
commit | 229242cf7c328b89b5aa65ed7a04e33c8b93b393 (patch) | |
tree | de0a9547e73e46490b0946d6850228d5b30258b8 /src/tools/Dtf/XPack | |
parent | f46ca6a9dce91607ffc9855270dd6998216e1a8b (diff) | |
download | wix-229242cf7c328b89b5aa65ed7a04e33c8b93b393.tar.gz wix-229242cf7c328b89b5aa65ed7a04e33c8b93b393.tar.bz2 wix-229242cf7c328b89b5aa65ed7a04e33c8b93b393.zip |
Rename "samples" segment to "tools"
This segment is a bit of a "miscellaneous section" in the WiX repo.
As such it has been difficult to name. I originally eschewed the
name "tools" because what is in the "wix" segment was once called
"tools". However, now that wix.exe is firmly established as the
entry point for WiX operations, I've become comfortable with its
segment being named "wix". That meant "tools" was again available
and "tools" better describes the content of this section.
Diffstat (limited to 'src/tools/Dtf/XPack')
-rw-r--r-- | src/tools/Dtf/XPack/AssemblyInfo.cs | 5 | ||||
-rw-r--r-- | src/tools/Dtf/XPack/XPack.cs | 80 | ||||
-rw-r--r-- | src/tools/Dtf/XPack/XPack.csproj | 27 |
3 files changed, 112 insertions, 0 deletions
diff --git a/src/tools/Dtf/XPack/AssemblyInfo.cs b/src/tools/Dtf/XPack/AssemblyInfo.cs new file mode 100644 index 00000000..6dfb9437 --- /dev/null +++ b/src/tools/Dtf/XPack/AssemblyInfo.cs | |||
@@ -0,0 +1,5 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | using System.Reflection; | ||
4 | |||
5 | [assembly: AssemblyDescription("Simple command-line CAB/ZIP packing and unpacking tool.")] | ||
diff --git a/src/tools/Dtf/XPack/XPack.cs b/src/tools/Dtf/XPack/XPack.cs new file mode 100644 index 00000000..cc52bb7d --- /dev/null +++ b/src/tools/Dtf/XPack/XPack.cs | |||
@@ -0,0 +1,80 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.Dtf.Tools.XPack | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using System.Collections.Generic; | ||
8 | using System.Text; | ||
9 | using WixToolset.Dtf.Compression; | ||
10 | |||
11 | public class XPack | ||
12 | { | ||
13 | public static void Usage(TextWriter writer) | ||
14 | { | ||
15 | writer.WriteLine("Usage: XPack /P <archive.cab> <directory>"); | ||
16 | writer.WriteLine("Usage: XPack /P <archive.zip> <directory>"); | ||
17 | writer.WriteLine(); | ||
18 | writer.WriteLine("Packs all files in a directory tree into an archive,"); | ||
19 | writer.WriteLine("using either the cab or zip format. Any existing archive"); | ||
20 | writer.WriteLine("with the same name will be overwritten."); | ||
21 | writer.WriteLine(); | ||
22 | writer.WriteLine("Usage: XPack /U <archive.cab> <directory>"); | ||
23 | writer.WriteLine("Usage: XPack /U <archive.zip> <directory>"); | ||
24 | writer.WriteLine(); | ||
25 | writer.WriteLine("Unpacks all files from a cab or zip archive to the"); | ||
26 | writer.WriteLine("specified directory. Any existing files with the same"); | ||
27 | writer.WriteLine("names will be overwritten."); | ||
28 | } | ||
29 | |||
30 | public static void Main(string[] args) | ||
31 | { | ||
32 | try | ||
33 | { | ||
34 | if (args.Length == 3 && args[0].ToUpperInvariant() == "/P") | ||
35 | { | ||
36 | ArchiveInfo a = GetArchive(args[1]); | ||
37 | a.Pack(args[2], true, CompressionLevel.Max, ProgressHandler); | ||
38 | } | ||
39 | else if (args.Length == 3 && args[0].ToUpperInvariant() == "/U") | ||
40 | { | ||
41 | ArchiveInfo a = GetArchive(args[1]); | ||
42 | a.Unpack(args[2], ProgressHandler); | ||
43 | } | ||
44 | else | ||
45 | { | ||
46 | Usage(Console.Out); | ||
47 | } | ||
48 | } | ||
49 | catch (Exception ex) | ||
50 | { | ||
51 | Console.WriteLine(ex); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | private static void ProgressHandler(object source, ArchiveProgressEventArgs e) | ||
56 | { | ||
57 | if (e.ProgressType == ArchiveProgressType.StartFile) | ||
58 | { | ||
59 | Console.WriteLine(e.CurrentFileName); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | private static ArchiveInfo GetArchive(string name) | ||
64 | { | ||
65 | string extension = Path.GetExtension(name).ToUpperInvariant(); | ||
66 | if (extension == ".CAB") | ||
67 | { | ||
68 | return new WixToolset.Dtf.Compression.Cab.CabInfo(name); | ||
69 | } | ||
70 | else if (extension == ".ZIP") | ||
71 | { | ||
72 | return new WixToolset.Dtf.Compression.Zip.ZipInfo(name); | ||
73 | } | ||
74 | else | ||
75 | { | ||
76 | throw new ArgumentException("Unknown archive file extension: " + extension); | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | } | ||
diff --git a/src/tools/Dtf/XPack/XPack.csproj b/src/tools/Dtf/XPack/XPack.csproj new file mode 100644 index 00000000..3e76de2e --- /dev/null +++ b/src/tools/Dtf/XPack/XPack.csproj | |||
@@ -0,0 +1,27 @@ | |||
1 | |||
2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
3 | |||
4 | |||
5 | <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
6 | <PropertyGroup> | ||
7 | <ProjectGuid>{03E55D95-DABE-4571-9CDA-92A44F92A465}</ProjectGuid> | ||
8 | <OutputType>Exe</OutputType> | ||
9 | <RootNamespace>WixToolset.Dtf.Tools.XPack</RootNamespace> | ||
10 | <AssemblyName>XPack</AssemblyName> | ||
11 | <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> | ||
12 | </PropertyGroup> | ||
13 | |||
14 | <ItemGroup> | ||
15 | <Compile Include="AssemblyInfo.cs" /> | ||
16 | <Compile Include="XPack.cs" /> | ||
17 | </ItemGroup> | ||
18 | |||
19 | <ItemGroup> | ||
20 | <Reference Include="System" /> | ||
21 | <ProjectReference Include="..\..\Libraries\Compression.Cab\Compression.Cab.csproj" /> | ||
22 | <ProjectReference Include="..\..\Libraries\Compression.Zip\Compression.Zip.csproj" /> | ||
23 | <ProjectReference Include="..\..\Libraries\Compression\Compression.csproj" /> | ||
24 | </ItemGroup> | ||
25 | |||
26 | <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.targets" /> | ||
27 | </Project> | ||