Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Common/src/CommandLine/CommandLineException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

namespace Internal.CommandLine
{
class CommandLineException : Exception
{
public CommandLineException(string message)
: base(message)
{
}
}
}
121 changes: 121 additions & 0 deletions src/Common/src/CommandLine/CommandLineParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.IO;

namespace Internal.CommandLine
{
//
// Simple command line parser
//
class CommandLineParser
{
string[] _args;
int _current;

string _currentOption;

public CommandLineParser(string[] args)
{
_args = args;
_current = 0;
}

public string GetOption()
{
if (_current >= _args.Length)
return null;

string opt = _args[_current];
_currentOption = opt;

if (opt.StartsWith("-"))
{
opt = opt.Substring(1);
}
#if !FXCORE
else
if (Path.DirectorySeparatorChar != '/' && opt.StartsWith("/"))
{
// For convenience, allow command line options starting with slash on Windows
opt = opt.Substring(1);
}
#endif
else
{
return "";
}

_current++;
return opt;
}

public string GetCurrentOption()
{
return _currentOption;
}

public string GetStringValue()
{
if (_current >= _args.Length)
throw new CommandLineException("Value expected for " + GetCurrentOption());

return _args[_current++];
}
public void AppendExpandedPaths(Dictionary<string, string> dictionary, bool strict)
{
string pattern = GetStringValue();

bool empty = true;

string directoryName = Path.GetDirectoryName(pattern);
string searchPattern = Path.GetFileName(pattern);

if (directoryName == "")
directoryName = ".";

if (Directory.Exists(directoryName))
{
foreach (string fileName in Directory.EnumerateFiles(directoryName, searchPattern))
{
#if !FXCORE
string fullFileName = Path.GetFullPath(fileName);
#else
string fullFileName = fileName;
#endif
string simpleName = Path.GetFileNameWithoutExtension(fileName);

if (dictionary.ContainsKey(simpleName))
{
if (strict)
{
throw new CommandLineException("Multiple input files matching same simple name " +
fullFileName + " " + dictionary[simpleName]);
}
}
else
{
dictionary.Add(simpleName, fullFileName);
}

empty = false;
}
}

if (empty)
{
if (strict)
{
throw new CommandLineException("No files matching " + pattern);
}
else
{
Console.WriteLine("Warning: No files matching " + pattern);
}
}
}

}
}
840 changes: 840 additions & 0 deletions src/JitInterface/src/CorInfoBase.cs

Large diffs are not rendered by default.

Loading