[RombaSharp] Slight restructuring

This commit is contained in:
Matt Nadareski
2016-08-30 16:55:51 -07:00
parent 4cce79a932
commit 9fc9449432

View File

@@ -329,34 +329,6 @@ CREATE TABLE IF NOT EXISTS data (
/// Populate or refresh the database information /// Populate or refresh the database information
/// </summary> /// </summary>
private void RefreshDatabase() private void RefreshDatabase()
{
// Make sure the dats dir is set
if (String.IsNullOrEmpty(_dats))
{
_dats = "dats";
}
// Make sure the folder exists
if (!Directory.Exists(_dats))
{
Directory.CreateDirectory(_dats);
}
// Now parse the directory into an internal Dat then insert
foreach (string file in Directory.EnumerateFiles(_dats, "*", SearchOption.AllDirectories))
{
Dat datdata = new Dat();
datdata = DatTools.Parse(file, 0, 0, datdata, _logger);
Rom romdata = FileTools.GetSingleFileInfo(file);
}
}
/// <summary>
/// Process a datfile and insert it into the database
/// </summary>
/// <param name="datdata">Dat object representing the data to insert</param>
/// <param name="romdata">Rom object representing the Dat file itself</param>
private void InsertDatIntoDatabase(Dat datdata, Rom romdata)
{ {
// Make sure the db is set // Make sure the db is set
if (String.IsNullOrEmpty(_db)) if (String.IsNullOrEmpty(_db))
@@ -372,22 +344,30 @@ CREATE TABLE IF NOT EXISTS data (
InitializeDatabase(); InitializeDatabase();
} }
// Open a connection to the database // Make sure the dats dir is set
using (SqliteConnection slc = new SqliteConnection(_connectionString)) if (String.IsNullOrEmpty(_dats))
{ {
// For each key _dats = "dats";
foreach (string key in datdata.Files.Keys)
{
// For each Rom in the list
foreach (Rom file in datdata.Files[key])
{
// Try to find the hash in the set
// If it exists, see if there's any missing information
// If it doesn't exist, insert it completely
} }
// Make sure the folder exists
if (!Directory.Exists(_dats))
{
Directory.CreateDirectory(_dats);
} }
// Now create a new structure to replace the database
List<Tuple<int, string, string>> keyvault = new List<Tuple<int, string, string>>();
// Now parse the directory into an internal Dat then insert
int i = 0;
foreach (string file in Directory.EnumerateFiles(_dats, "*", SearchOption.AllDirectories))
{
Dat datdata = new Dat();
datdata = DatTools.Parse(file, 0, 0, datdata, _logger);
Rom romdata = FileTools.GetSingleFileInfo(file);
// Loop through the entire deduped DAT and add to the structure
} }
} }
} }