mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Cleanup and overhaul (#21)
* Syntax cleanup * More minor cleanup, use Linq * Fix broken features by using correct values * Feature flags the same * Features are modular * No AlphaFS, more .NET versions * Fix appveyor * Put back identifiers, for some reason * String interpolation, modernization * Better use of GetField * XmlTextWriter to remove possible issues * Fix header for OpenMSX
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
using Mono.Data.Sqlite;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using SabreTools.Library.Data;
|
||||
|
||||
#if MONO
|
||||
using System.IO;
|
||||
#else
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
#endif
|
||||
using Mono.Data.Sqlite;
|
||||
|
||||
namespace SabreTools.Library.Tools
|
||||
{
|
||||
@@ -34,19 +29,16 @@ namespace SabreTools.Library.Tools
|
||||
SqliteConnection dbc = new SqliteConnection(Constants.HeadererConnectionString);
|
||||
dbc.Open();
|
||||
|
||||
string query = @"SELECT * FROM data WHERE sha1='" + SHA1 + "' AND header='" + header + "'";
|
||||
string query = $"SELECT * FROM data WHERE sha1='{SHA1}' AND header='{header}'";
|
||||
SqliteCommand slc = new SqliteCommand(query, dbc);
|
||||
SqliteDataReader sldr = slc.ExecuteReader();
|
||||
exists = sldr.HasRows;
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
query = @"INSERT INTO data (sha1, header, type) VALUES ('" +
|
||||
SHA1 + "', " +
|
||||
"'" + header + "', " +
|
||||
"'" + source + "')";
|
||||
query = $"INSERT INTO data (sha1, header, type) VALUES ('{SHA1}', '{header}', '{source}')";
|
||||
slc = new SqliteCommand(query, dbc);
|
||||
Globals.Logger.Verbose("Result of inserting header: {0}", slc.ExecuteNonQuery());
|
||||
Globals.Logger.Verbose($"Result of inserting header: {slc.ExecuteNonQuery()}");
|
||||
}
|
||||
|
||||
// Dispose of database objects
|
||||
@@ -68,9 +60,7 @@ namespace SabreTools.Library.Tools
|
||||
|
||||
// Make sure the file exists
|
||||
if (!File.Exists(db))
|
||||
{
|
||||
SqliteConnection.CreateFile(db);
|
||||
}
|
||||
|
||||
// Open the database connection
|
||||
SqliteConnection dbc = new SqliteConnection(connectionString);
|
||||
@@ -174,7 +164,7 @@ CREATE TABLE IF NOT EXISTS data (
|
||||
// Create the output list of headers
|
||||
List<string> headers = new List<string>();
|
||||
|
||||
string query = @"SELECT header, type FROM data WHERE sha1='" + SHA1 + "'";
|
||||
string query = $"SELECT header, type FROM data WHERE sha1='{SHA1}'";
|
||||
SqliteCommand slc = new SqliteCommand(query, dbc);
|
||||
SqliteDataReader sldr = slc.ExecuteReader();
|
||||
|
||||
@@ -182,7 +172,7 @@ CREATE TABLE IF NOT EXISTS data (
|
||||
{
|
||||
while (sldr.Read())
|
||||
{
|
||||
Globals.Logger.Verbose("Found match with rom type '{0}'", sldr.GetString(1));
|
||||
Globals.Logger.Verbose($"Found match with rom type '{sldr.GetString(1)}'");
|
||||
headers.Add(sldr.GetString(0));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user