-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds xfo and xfr commands to CLI to extract files from msi with…
…out the path into a flat directory structure closes #174 New Commands: xfo Extracts all or specified files from the specified msi_name to the same folder while overwriting files with the same name. xfr Extracts all or specified files from the specified msi_name to the same folder while renaming files with the same name with a count suffix. Thanks @mega5800
- Loading branch information
Showing
18 changed files
with
1,513 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ src/.build/nuget.exe | |
src/msbuild.log | ||
src/.vs/ | ||
src/.temp/ | ||
.vs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,53 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using NDesk.Options; | ||
|
||
namespace LessMsi.Cli | ||
{ | ||
internal class ExtractCommand : LessMsiCommand | ||
{ | ||
public override void Run(List<string> allArgs) | ||
{ | ||
var args = allArgs.Skip(1).ToList(); | ||
// "x msi_name [path_to_extract\] [file_names]+ | ||
if (args.Count < 1) | ||
throw new OptionException("Invalid argument. Extract command must at least specify the name of an msi file.", "x"); | ||
|
||
var i = 0; | ||
var msiFile = args[i++]; | ||
if (!File.Exists(msiFile)) | ||
throw new OptionException("Invalid argument. Specified msi file does not exist.", "x"); | ||
var filesToExtract = new List<string>(); | ||
var extractDir = ""; | ||
if (i < args.Count) | ||
{ | ||
if (extractDir == "" && (args[i].EndsWith("\\") || args[i].EndsWith("\""))) | ||
extractDir = args[i]; | ||
else | ||
filesToExtract.Add(args[i]); | ||
} | ||
while (++i < args.Count) | ||
filesToExtract.Add(args[i]); | ||
|
||
Program.DoExtraction(msiFile, extractDir.TrimEnd('\"'), filesToExtract); | ||
} | ||
} | ||
namespace LessMsi.Cli | ||
{ | ||
internal class ExtractCommand : LessMsiCommand | ||
{ | ||
public override void Run(List<string> allArgs) | ||
{ | ||
var args = allArgs.Skip(1).ToList(); | ||
// "x msi_name [path_to_extract\] [file_names]+ | ||
if (args.Count < 1) | ||
throw new OptionException("Invalid argument. Extract command must at least specify the name of an msi file.", "x"); | ||
|
||
var i = 0; | ||
var msiFile = args[i++]; | ||
if (!File.Exists(msiFile)) | ||
throw new OptionException("Invalid argument. Specified msi file does not exist.", "x"); | ||
var filesToExtract = new List<string>(); | ||
var extractDir = ""; | ||
if (i < args.Count) | ||
{ | ||
if (extractDir == "" && (args[i].EndsWith("\\") || args[i].EndsWith("\""))) | ||
extractDir = args[i]; | ||
else | ||
filesToExtract.Add(args[i]); | ||
} | ||
while (++i < args.Count) | ||
filesToExtract.Add(args[i]); | ||
|
||
Program.DoExtraction(msiFile, extractDir.TrimEnd('\"'), filesToExtract, getExtractionMode(allArgs[0])); | ||
} | ||
|
||
private ExtractionMode getExtractionMode(string commandArgument) | ||
{ | ||
commandArgument = commandArgument.ToLowerInvariant(); | ||
ExtractionMode extractionMode = ExtractionMode.PreserveDirectoriesExtraction; | ||
|
||
if (commandArgument[commandArgument.Length - 1] == 'o') | ||
{ | ||
extractionMode = ExtractionMode.OverwriteFlatExtraction; | ||
} | ||
else if (commandArgument[commandArgument.Length - 1] == 'r') | ||
{ | ||
extractionMode = ExtractionMode.RenameFlatExtraction; | ||
} | ||
|
||
return extractionMode; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace LessMsi.Cli | ||
{ | ||
public enum ExtractionMode | ||
{ | ||
/// <summary> | ||
/// Default value indicating that no extraction should be performed. | ||
/// </summary> | ||
None, | ||
/// <summary> | ||
/// Value indicating that a file extraction preserving directories should be performed. | ||
/// </summary> | ||
PreserveDirectoriesExtraction, | ||
/// <summary> | ||
/// Value indicating that a file extraction renaming identical files should be performed. | ||
/// </summary> | ||
RenameFlatExtraction, | ||
/// <summary> | ||
/// Value indicating that a file extraction overwriting identical files should be performed. | ||
/// </summary> | ||
OverwriteFlatExtraction | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.