mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[FileTools, DatFile] Get ready for CSV/TSV parsing
This commit is contained in:
@@ -59,6 +59,13 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// <param name="descAsName">True if descriptions should be used as names, false otherwise (default)</param>
|
/// <param name="descAsName">True if descriptions should be used as names, false otherwise (default)</param>
|
||||||
/// <param name="keepext">True if original extension should be kept, false otherwise (default)</param>
|
/// <param name="keepext">True if original extension should be kept, false otherwise (default)</param>
|
||||||
/// <param name="useTags">True if tags from the DAT should be used to merge the output, false otherwise (default)</param>
|
/// <param name="useTags">True if tags from the DAT should be used to merge the output, false otherwise (default)</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// TODO: Add CSV and TSV parsing.
|
||||||
|
/// Can they be in the same parser? All it would technically need is the delimiter that it should be looking
|
||||||
|
/// for and it would be able to read them individually. Also, take into account different types of formats,
|
||||||
|
/// possibly by looking at the first line headings, determining what columns those correspond to, and then
|
||||||
|
/// keeping track of what goes to what in the map. That would allow for a VERY flexible reading of inputs.
|
||||||
|
/// </remarks>
|
||||||
public void Parse(
|
public void Parse(
|
||||||
// Standard Dat parsing
|
// Standard Dat parsing
|
||||||
string filename,
|
string filename,
|
||||||
@@ -88,7 +95,7 @@ namespace SabreTools.Helper.Dats
|
|||||||
{
|
{
|
||||||
ext = ext.Substring(1);
|
ext = ext.Substring(1);
|
||||||
}
|
}
|
||||||
if (ext != "dat" && ext != "md5" && ext != "sfv" && ext != "sha1" && ext != "sha256" && ext != "txt" && ext != "xml")
|
if (ext != "dat" && ext != "csv" && ext != "md5" && ext != "sfv" && ext != "sha1" && ext != "sha256" && ext != "tsv" && ext != "txt" && ext != "xml")
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -109,6 +116,9 @@ namespace SabreTools.Helper.Dats
|
|||||||
case DatFormat.DOSCenter:
|
case DatFormat.DOSCenter:
|
||||||
ParseCMP(filename, sysid, srcid, filter, trim, single, root, logger, keep, clean, descAsName);
|
ParseCMP(filename, sysid, srcid, filter, trim, single, root, logger, keep, clean, descAsName);
|
||||||
break;
|
break;
|
||||||
|
case DatFormat.CSV:
|
||||||
|
// Nothing yet
|
||||||
|
break;
|
||||||
case DatFormat.Logiqx:
|
case DatFormat.Logiqx:
|
||||||
case DatFormat.OfflineList:
|
case DatFormat.OfflineList:
|
||||||
case DatFormat.SabreDat:
|
case DatFormat.SabreDat:
|
||||||
@@ -130,6 +140,9 @@ namespace SabreTools.Helper.Dats
|
|||||||
case DatFormat.RomCenter:
|
case DatFormat.RomCenter:
|
||||||
ParseRC(filename, sysid, srcid, filter, trim, single, root, logger, clean, descAsName);
|
ParseRC(filename, sysid, srcid, filter, trim, single, root, logger, clean, descAsName);
|
||||||
break;
|
break;
|
||||||
|
case DatFormat.TSV:
|
||||||
|
// Nothing yet
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace SabreTools.Helper.Tools
|
|||||||
{
|
{
|
||||||
ext = ext.Substring(1);
|
ext = ext.Substring(1);
|
||||||
}
|
}
|
||||||
if (ext != "dat" && ext != "md5" && ext != "sfv" && ext != "sha1" && ext != "txt" && ext != "xml")
|
if (ext != "csv" && ext != "dat" && ext != "md5" && ext != "sfv" && ext != "sha1" && ext != "tsv" && ext != "txt" && ext != "xml")
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -101,6 +101,10 @@ namespace SabreTools.Helper.Tools
|
|||||||
{
|
{
|
||||||
return DatFormat.RedumpSHA1;
|
return DatFormat.RedumpSHA1;
|
||||||
}
|
}
|
||||||
|
if (ext == "sha256")
|
||||||
|
{
|
||||||
|
return DatFormat.RedumpSHA256;
|
||||||
|
}
|
||||||
|
|
||||||
// For everything else, we need to read it
|
// For everything else, we need to read it
|
||||||
try
|
try
|
||||||
@@ -160,6 +164,14 @@ namespace SabreTools.Helper.Tools
|
|||||||
{
|
{
|
||||||
return DatFormat.AttractMode;
|
return DatFormat.AttractMode;
|
||||||
}
|
}
|
||||||
|
else if (first.Contains("\"File Name\",\"Internal Name\",\"Description\""))
|
||||||
|
{
|
||||||
|
return DatFormat.CSV;
|
||||||
|
}
|
||||||
|
else if (first.Contains("\"File Name\"\t\"Internal Name\"\t\"Description\""))
|
||||||
|
{
|
||||||
|
return DatFormat.TSV;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return DatFormat.ClrMamePro;
|
return DatFormat.ClrMamePro;
|
||||||
|
|||||||
Reference in New Issue
Block a user