-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathApp.xaml.cs
103 lines (97 loc) · 2.32 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using CommandLine;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows;
namespace nsZip
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
//var outDebug = new Output();
//var tl1 = new TaskLogic(@"T:\OUT", @"T:\", true, 262144, 18, outDebug);
//tl1.VerifyCompressedFolder(@"T:\NSP\input.nsp");
//return;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
try
{
if (ConsoleMode.TryDisablingConsoleQuickEdit())
{
Console.WriteLine("Console's QuickEdit mode disabled successfully");
}
else
{
Console.WriteLine("Failed to disable the Console's QuickEdit mode");
}
}
catch (Exception)
{
Console.WriteLine("Unimportant exception occurred while disabling Console's QuickEdit mode");
}
}
if (e.Args.Length > 0)
{
int res = 0;
var args = Parser.Default.ParseArguments<Options>(e.Args);
if (e.Args.Length > 0)
{
args.WithParsed(opts => {
var Out = new Output(opts.Log);
Directory.CreateDirectory(opts.OutputFolderPath);
var tl = new TaskLogic(opts.OutputFolderPath, opts.TempFolderPath, true, opts.BlockSize, opts.ZstdLevel, opts.MaxDegreeOfParallelism, Out);
var inFile = opts.InputFile;
if (tl.checkIfAlreadyExist(inFile))
{
Environment.Exit(-1);
}
try
{
tl.cleanFolders();
var infileLowerCase = inFile.ToLower();
if (infileLowerCase.EndsWith("nsp"))
{
tl.CompressNSP(inFile);
}
else if (infileLowerCase.EndsWith("xci"))
{
tl.CompressXCI(inFile);
}
else if (infileLowerCase.EndsWith("nspz"))
{
tl.DecompressNSPZ(inFile);
}
else if (infileLowerCase.EndsWith("xciz"))
{
tl.DecompressXCIZ(inFile);
}
else
{
throw new InvalidDataException($"Invalid file type {inFile}");
}
}
catch (Exception ex)
{
Out.LogException(ex);
res = -2;
}
finally
{
tl.cleanFolders();
}
});
}
Environment.Exit(res);
}
else
{
MainWindow wnd = new MainWindow();
wnd.Show();
}
}
}
}