Update Program.cs
This commit is contained in:
13
BoerseDataConvert/BoerseDataConvert/Model/Params.cs
Normal file
13
BoerseDataConvert/BoerseDataConvert/Model/Params.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BoerseDataConvert
|
||||||
|
{
|
||||||
|
class Params
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"BoerseDataConvert": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"commandLineArgs": "-i TestData-2021_07_02.zip -d input -o output -t \"D:\\Code\\ИТ Кариера\\Стаж\\github\\BoerseDataConvert\\tags.txt\""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,13 +38,13 @@ namespace BoerseDataConvert
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CheckFreeDisk(outputDir);
|
CheckFreeDisk(zipFile, outputDir);
|
||||||
ZipExtract(zipFile, inputDir);
|
ZipExtract(zipFile, inputDir);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(e.Message);
|
Console.Error.WriteLine(e.Message);
|
||||||
Environment.Exit(0);
|
Environment.Exit(Environment.ExitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only read filenames
|
// only read filenames
|
||||||
@@ -82,17 +82,19 @@ namespace BoerseDataConvert
|
|||||||
Console.WriteLine("-h or --help - Prints this message");
|
Console.WriteLine("-h or --help - Prints this message");
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
static void CheckFreeDisk(string outputDir)
|
static void CheckFreeDisk(string zipFile, string outputDir)
|
||||||
{
|
{
|
||||||
double gibibyte = 1073741824;
|
double gibibyte = 1073741824;
|
||||||
DriveInfo driveInfo = new DriveInfo(Directory.GetDirectoryRoot(outputDir));
|
DriveInfo driveInfo = new DriveInfo(Directory.GetDirectoryRoot(outputDir));
|
||||||
double availableSpace = driveInfo.AvailableFreeSpace;
|
double availableSpace = driveInfo.AvailableFreeSpace;
|
||||||
Console.WriteLine($"INFO: {availableSpace / gibibyte}GiB available");
|
FileInfo fi = new FileInfo(zipFile);
|
||||||
if (availableSpace < 2147483648)
|
double checkedSpace = fi.Length * 100;
|
||||||
|
if (availableSpace < checkedSpace)
|
||||||
{
|
{
|
||||||
Environment.ExitCode = 3;
|
Environment.ExitCode = 3;
|
||||||
throw new IOException($"ERROR: Insufficient disk space, {availableSpace / gibibyte}GiB less than 2GiB");
|
throw new IOException($"ERROR: Estimated required space: {checkedSpace / gibibyte:f2}GiB. Available: {availableSpace / gibibyte:f2}GiB");
|
||||||
}
|
}
|
||||||
|
Console.WriteLine($"INFO: {availableSpace / gibibyte:f2}GiB available");
|
||||||
}
|
}
|
||||||
static string[] InputValidate(string[] args)
|
static string[] InputValidate(string[] args)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user