[RombaSharp] Get more skeleton methods started

This commit is contained in:
Matt Nadareski
2016-09-08 17:42:53 -07:00
parent 1a2e50ed07
commit 9f2d0e10bc
2 changed files with 48 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Xml; using System.Xml;
namespace SabreTools namespace SabreTools
@@ -435,6 +436,33 @@ namespace SabreTools
} }
} }
/// <summary>
/// Gets all valid DATs that match in the DAT root
/// </summary>
/// <param name="inputs">List of input strings to check for, presumably file names</param>
/// <returns>Dictionary of hash/full path for each of the valid DATs</returns>
private static Dictionary<string, string> GetValidDats(List<string> inputs)
{
// Get a dictionary of filenames that actually exist in the DATRoot, logging which ones are not
List<string> datRootDats = Directory.EnumerateFiles(_dats, "*", SearchOption.AllDirectories).ToList().ConvertAll(i => i.ToLowerInvariant());
Dictionary<string, string> foundDats = new Dictionary<string, string>();
foreach (string input in inputs)
{
if (datRootDats.Contains(input.ToLowerInvariant()))
{
string fullpath = Path.GetFullPath(datRootDats[datRootDats.IndexOf(input.ToLowerInvariant())]);
string sha1 = FileTools.GetSingleFileInfo(fullpath).HashData.SHA1;
foundDats.Add(sha1, fullpath);
}
else
{
_logger.Warning("The file '" + input + "' could not be found in the DAT root");
}
}
return foundDats;
}
#endregion #endregion
} }
} }

View File

@@ -16,6 +16,11 @@ namespace SabreTools
private static void InitArchive(List<string> inputs, bool onlyNeeded) private static void InitArchive(List<string> inputs, bool onlyNeeded)
{ {
_logger.User("This feature is not yet implemented: archive"); _logger.User("This feature is not yet implemented: archive");
// This should use the same thing as something like in SimpleSort, as in scan the archive and scan the files inside equally
// Either during or after, we then check against the database to see if there's any matches. If there's no match and
// we say onlyNeeded, then don't add it. If there's no match and not onlyNeeded, add it with no DAT hash. If there's a match,
// and it doesn't say exists, add it and change the flag. If there's a match and says exists, skip it.
} }
/// <summary> /// <summary>
@@ -25,6 +30,12 @@ namespace SabreTools
private static void InitBuild(List<string> inputs) private static void InitBuild(List<string> inputs)
{ {
_logger.User("This feature is not yet implemented: build"); _logger.User("This feature is not yet implemented: build");
// Verify the filenames
Dictionary<string, string> foundDats = GetValidDats(inputs);
// Now that we have the dictionary, we can loop through and output to a new folder for each
} }
/// <summary> /// <summary>
@@ -34,6 +45,9 @@ namespace SabreTools
private static void InitDiffDat(string newdat) private static void InitDiffDat(string newdat)
{ {
_logger.User("This feature is not yet implemented: diffdat"); _logger.User("This feature is not yet implemented: diffdat");
// First, we want to read in the DAT. Then for each file listed in the DAT, we check if it's in there or not.
// If it is in there, we add it to an output DAT. If it's not, we skip. Then we output the DAT.
} }
/// <summary> /// <summary>
@@ -63,6 +77,9 @@ namespace SabreTools
private static void InitFixdat(List<string> inputs) private static void InitFixdat(List<string> inputs)
{ {
_logger.User("This feature is not yet implemented: fixdat"); _logger.User("This feature is not yet implemented: fixdat");
// Verify the filenames
Dictionary<string, string> foundDats = GetValidDats(inputs);
} }
/// <summary> /// <summary>
@@ -81,6 +98,9 @@ namespace SabreTools
private static void InitMiss(List<string> inputs) private static void InitMiss(List<string> inputs)
{ {
_logger.User("This feature is not yet implemented: miss"); _logger.User("This feature is not yet implemented: miss");
// Verify the filenames
Dictionary<string, string> foundDats = GetValidDats(inputs);
} }
#endregion #endregion