mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-12 10:55:27 +00:00
Added support for specifying an output file directly via "-o" (instead of redirecting console output).
This commit is contained in:
parent
2ab2af9e95
commit
29b8415a0d
|
@ -73,6 +73,7 @@ namespace CHeaderToXML
|
||||||
bool showHelp = false;
|
bool showHelp = false;
|
||||||
string prefix = "gl";
|
string prefix = "gl";
|
||||||
string version = null;
|
string version = null;
|
||||||
|
string path = null;
|
||||||
HeaderType type = HeaderType.Header;
|
HeaderType type = HeaderType.Header;
|
||||||
OptionSet opts = new OptionSet
|
OptionSet opts = new OptionSet
|
||||||
{
|
{
|
||||||
|
@ -83,6 +84,8 @@ namespace CHeaderToXML
|
||||||
v => version = v },
|
v => version = v },
|
||||||
{ "t:", "The {TYPE} of the headers being parsed.",
|
{ "t:", "The {TYPE} of the headers being parsed.",
|
||||||
v => type = (HeaderType)Enum.Parse(typeof(HeaderType), v, true) },
|
v => type = (HeaderType)Enum.Parse(typeof(HeaderType), v, true) },
|
||||||
|
{ "o:", "The {PATH} to the output file.",
|
||||||
|
v => path = v },
|
||||||
{ "?|h|help", "Show this message and exit.",
|
{ "?|h|help", "Show this message and exit.",
|
||||||
v => showHelp = v != null },
|
v => showHelp = v != null },
|
||||||
};
|
};
|
||||||
|
@ -119,9 +122,19 @@ namespace CHeaderToXML
|
||||||
var settings = new XmlWriterSettings();
|
var settings = new XmlWriterSettings();
|
||||||
settings.Indent = true;
|
settings.Indent = true;
|
||||||
settings.Encoding = System.Text.Encoding.UTF8;
|
settings.Encoding = System.Text.Encoding.UTF8;
|
||||||
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
|
||||||
|
|
||||||
using (var writer = XmlWriter.Create(Console.Out, settings))
|
TextWriter out_stream = null;
|
||||||
|
if (path == null)
|
||||||
|
{
|
||||||
|
out_stream = Console.Out;
|
||||||
|
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out_stream = new StreamWriter(path, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var writer = XmlWriter.Create(out_stream, settings))
|
||||||
{
|
{
|
||||||
new XElement("signatures",
|
new XElement("signatures",
|
||||||
entries.Values.OrderBy(s => s.Attribute("name").Value), // only enums
|
entries.Values.OrderBy(s => s.Attribute("name").Value), // only enums
|
||||||
|
@ -132,6 +145,8 @@ namespace CHeaderToXML
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
writer.Close();
|
writer.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out_stream.Dispose();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue