Skip to content

Commit

Permalink
Work around dotnet randomly inserting the executable as the first arg…
Browse files Browse the repository at this point in the history
…ument
  • Loading branch information
RA-Kooi committed Dec 21, 2021
1 parent 5096d8c commit 03bb5f1
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions DwarfOne2C/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Collections.Generic;

namespace DwarfOne2C
{
Expand Down Expand Up @@ -41,33 +42,53 @@ static void Help()

static int Main(string[] args)
{
if(args.Length < 1
&& (args.Length < 2 && args[0].ToLower() == "--list-files")
&& args.Length < 3
&& args.Length > 4)
List<string> arguments = new(args);

if(arguments.Count > 0 && arguments[0].ToLower().Contains("dwarfone2c"))
arguments.RemoveAt(0);

if(arguments.Count < 1)
{
Usage();
return 1;
}
else if(arguments.Count < 2 && arguments[0].ToLower() == "--list-files")
{
Usage();
return 1;
}
else if((arguments.Count < 3 || arguments.Count > 4)
&& !(arguments[0].ToLower() == "--help")
&& !(arguments[0].ToLower() == "--list-files"))
{
Usage();
return 1;
}

if(args[0].ToLower() == "--help")
if(arguments[0].ToLower() == "--help")
{
Help();
return 1;
}

string fileName = args[0];
string fullPath = Path.GetFullPath(fileName);
string fileName = null;
string fullPath = null;

if(args[0].ToLower() == "--list-files")
if(arguments[0].ToLower() == "--list-files")
{
fileName = arguments[1];
fullPath = Path.GetFullPath(fileName);

ListFiles(fullPath);
return 0;
}

fileName = arguments[0];
fullPath = Path.GetFullPath(fileName);

string outputDirectory = null;
if(args.Length > 3)
outputDirectory = Path.GetFullPath(args[3]);
if(arguments.Count > 3)
outputDirectory = Path.GetFullPath(arguments[3]);
else
outputDirectory = Path.GetDirectoryName(fullPath);

Expand Down Expand Up @@ -100,8 +121,8 @@ static int Main(string[] args)
return 1;
}

string splitPath = args[1];
string cuPath = args[2];
string splitPath = arguments[1];
string cuPath = arguments[2];

DumpParser dumpParser = new DumpParser(fullPath);

Expand Down

0 comments on commit 03bb5f1

Please sign in to comment.