mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[RombaSharp] Add export to RombaSharp
This commit is contained in:
@@ -295,6 +295,42 @@ namespace SabreTools
|
|||||||
_logger.User("User Processor Time: " + proc.UserProcessorTime);
|
_logger.User("User Processor Time: " + proc.UserProcessorTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Export the current database to CSV
|
||||||
|
/// </summary>
|
||||||
|
private static void ExportDatabase()
|
||||||
|
{
|
||||||
|
SqliteConnection dbc = new SqliteConnection(_connectionString);
|
||||||
|
dbc.Open();
|
||||||
|
StreamWriter sw = new StreamWriter(File.Open("export.csv", FileMode.Create, FileAccess.Write));
|
||||||
|
|
||||||
|
sw.WriteLine("\"ID\",\"Size\",\"CRC\",\"MD5\",\"SHA-1\",\"In Depot\",\"DAT Hash\"");
|
||||||
|
|
||||||
|
string query = "SELECT dats.id, size, crc, md5, sha1, indepot, hash FROM data JOIN dats ON data.id=dats.id";
|
||||||
|
SqliteCommand slc = new SqliteCommand(query, dbc);
|
||||||
|
SqliteDataReader sldr = slc.ExecuteReader();
|
||||||
|
|
||||||
|
if (sldr.HasRows)
|
||||||
|
{
|
||||||
|
while (sldr.Read())
|
||||||
|
{
|
||||||
|
string line = "\"" + sldr.GetInt32(0) + "\","
|
||||||
|
+ "\"" + sldr.GetInt64(1) + "\","
|
||||||
|
+ "\"" + sldr.GetString(2) + "\","
|
||||||
|
+ "\"" + sldr.GetString(3) + "\","
|
||||||
|
+ "\"" + sldr.GetString(4) + "\","
|
||||||
|
+ "\"" + sldr.GetInt32(5) + "\","
|
||||||
|
+ "\"" + sldr.GetString(6) + "\"";
|
||||||
|
sw.WriteLine(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sldr.Dispose();
|
||||||
|
slc.Dispose();
|
||||||
|
sw.Dispose();
|
||||||
|
dbc.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Moves DAT index entries for orphaned DATs to backup folder
|
/// Moves DAT index entries for orphaned DATs to backup folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ namespace SabreTools
|
|||||||
dbstats = false,
|
dbstats = false,
|
||||||
diffdat = false,
|
diffdat = false,
|
||||||
dir2dat = false,
|
dir2dat = false,
|
||||||
|
export = false,
|
||||||
fixdat = false,
|
fixdat = false,
|
||||||
lookup = false,
|
lookup = false,
|
||||||
memstats = false,
|
memstats = false,
|
||||||
@@ -117,6 +118,9 @@ namespace SabreTools
|
|||||||
case "dir2dat":
|
case "dir2dat":
|
||||||
dir2dat = true;
|
dir2dat = true;
|
||||||
break;
|
break;
|
||||||
|
case "export":
|
||||||
|
export = true;
|
||||||
|
break;
|
||||||
case "fixdat":
|
case "fixdat":
|
||||||
fixdat = true;
|
fixdat = true;
|
||||||
break;
|
break;
|
||||||
@@ -176,8 +180,8 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If more than one switch is enabled, show the help screen
|
// If more than one switch is enabled, show the help screen
|
||||||
if (!(archive ^ build ^ dbstats ^ diffdat ^ dir2dat ^ fixdat ^ lookup ^ memstats ^ miss ^
|
if (!(archive ^ build ^ dbstats ^ diffdat ^ dir2dat ^ export ^ fixdat ^ lookup ^ memstats ^
|
||||||
progress ^ purgeBackup ^ purgeDelete ^ refreshDats ^ shutdown))
|
miss ^ progress ^ purgeBackup ^ purgeDelete ^ refreshDats ^ shutdown))
|
||||||
{
|
{
|
||||||
_logger.Error("Only one feature switch is allowed at a time");
|
_logger.Error("Only one feature switch is allowed at a time");
|
||||||
Build.Help();
|
Build.Help();
|
||||||
@@ -226,6 +230,12 @@ namespace SabreTools
|
|||||||
InitDir2Dat(inputs);
|
InitDir2Dat(inputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Export the database to file
|
||||||
|
else if (export)
|
||||||
|
{
|
||||||
|
ExportDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
// For each specified DAT file it creates a fix DAT
|
// For each specified DAT file it creates a fix DAT
|
||||||
else if (fixdat)
|
else if (fixdat)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ namespace SabreTools.Helper
|
|||||||
helptext.Add(" -new= DAT to compare to");
|
helptext.Add(" -new= DAT to compare to");
|
||||||
helptext.Add(" dir2dat Creates a DAT file for the specified input directory");
|
helptext.Add(" dir2dat Creates a DAT file for the specified input directory");
|
||||||
helptext.Add(" -out= Filename to save out to");
|
helptext.Add(" -out= Filename to save out to");
|
||||||
|
helptext.Add(" export Exports db to export.csv");
|
||||||
helptext.Add(" fixdat For each specified DAT file it creates a fix DAT");
|
helptext.Add(" fixdat For each specified DAT file it creates a fix DAT");
|
||||||
helptext.Add(" lookup For each specified hash, look up available information");
|
helptext.Add(" lookup For each specified hash, look up available information");
|
||||||
helptext.Add(" memstats Prints memory stats");
|
helptext.Add(" memstats Prints memory stats");
|
||||||
|
|||||||
Reference in New Issue
Block a user