2016-09-02 14:13:44 -07:00
|
|
|
|
using SabreTools.Helper;
|
2016-09-02 13:59:25 -07:00
|
|
|
|
using System.Collections.Generic;
|
2016-09-02 14:13:44 -07:00
|
|
|
|
using System.IO;
|
2016-09-02 13:59:25 -07:00
|
|
|
|
|
|
|
|
|
|
namespace SabreTools
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class RombaSharp
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Init Methods
|
|
|
|
|
|
|
2016-09-02 14:08:34 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Wrap adding files to the depots
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="inputs"></param>
|
|
|
|
|
|
/// <param name="onlyNeeded"></param>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static void InitArchive(List<string> inputs, bool onlyNeeded)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.User("This feature is not yet implemented: archive");
|
2016-09-08 17:42:53 -07:00
|
|
|
|
|
|
|
|
|
|
// 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.
|
2016-09-02 13:59:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-02 14:08:34 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Wrap building all files from a set of DATs
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="inputs"></param>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static void InitBuild(List<string> inputs)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.User("This feature is not yet implemented: build");
|
2016-09-08 17:42:53 -07:00
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
2016-09-02 13:59:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-02 14:08:34 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Wrap finding all files that are in both the database and a new Dat
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="newdat"></param>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static void InitDiffDat(string newdat)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.User("This feature is not yet implemented: diffdat");
|
2016-09-08 17:42:53 -07:00
|
|
|
|
|
|
|
|
|
|
// 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.
|
2016-09-02 13:59:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-02 14:08:34 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Wrap creating a Dat from a directory
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="inputs"></param>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static void InitDir2Dat(List<string> inputs)
|
|
|
|
|
|
{
|
2016-09-02 14:13:44 -07:00
|
|
|
|
// Create a simple Dat output
|
2016-09-19 20:08:25 -07:00
|
|
|
|
DatFile datdata = new DatFile()
|
2016-09-02 14:13:44 -07:00
|
|
|
|
{
|
|
|
|
|
|
FileName = Path.GetFileName(inputs[0]) + " Dir2Dat",
|
|
|
|
|
|
Name = Path.GetFileName(inputs[0]) + " Dir2Dat",
|
|
|
|
|
|
Description = Path.GetFileName(inputs[0]) + " Dir2Dat",
|
2016-09-09 15:51:47 -07:00
|
|
|
|
OutputFormat = OutputFormat.Xml,
|
2016-09-19 18:04:24 -07:00
|
|
|
|
Files = new Dictionary<string, List<DatItem>>(),
|
2016-09-02 14:13:44 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2016-09-14 14:53:48 -07:00
|
|
|
|
Logger logger = new Logger(false, "");
|
|
|
|
|
|
foreach (string input in inputs)
|
|
|
|
|
|
{
|
2016-09-22 17:46:21 -07:00
|
|
|
|
datdata.PopulateDatFromDir(input, false /* noMD5 */, false /* noSHA1 */, true /* bare */, false /* archivesAsFiles */,
|
|
|
|
|
|
true /* enableGzip */, false /* addBlanks */, false /* addDate */, "__temp__" /* tempDir */, false /* copyFiles */, 4 /* maxDegreeOfParallelism */, _logger);
|
|
|
|
|
|
datdata.WriteToFile("", logger);
|
2016-09-14 14:53:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
logger.Close();
|
2016-09-02 13:59:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-02 14:08:34 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Wrap creating a fixdat for each Dat
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="inputs"></param>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static void InitFixdat(List<string> inputs)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.User("This feature is not yet implemented: fixdat");
|
2016-09-08 17:42:53 -07:00
|
|
|
|
|
|
|
|
|
|
// Verify the filenames
|
|
|
|
|
|
Dictionary<string, string> foundDats = GetValidDats(inputs);
|
2016-09-08 17:52:02 -07:00
|
|
|
|
|
|
|
|
|
|
// Once we have each DAT, look up each associated hash based on the hash of the DATs.
|
|
|
|
|
|
// Then, for each rom, check to see if they exist in the folder. If they don't, add it
|
|
|
|
|
|
// to the fixDAT. Then output when the DAT is done, processing, moving on to the next...
|
|
|
|
|
|
// NOTE: This might share code with InitMiss
|
2016-09-02 13:59:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-02 14:08:34 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Wrap looking up if hashes exist in the database
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="inputs"></param>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static void InitLookup(List<string> inputs)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.User("This feature is not yet implemented: lookup");
|
2016-09-08 17:52:02 -07:00
|
|
|
|
|
|
|
|
|
|
// First things first is that the inputs have to be lower-cased. Then, we have to check
|
|
|
|
|
|
// to see what sort of hashes we're dealing with. Like [0-9a-f]{8} for CRC. Might add
|
|
|
|
|
|
// these to the constants while I'm at it. Once we have the hashes separated, we check
|
|
|
|
|
|
// and add a simple bool for each that's found.
|
2016-09-02 13:59:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-02 14:08:34 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Wrap creating a havefile and a missfile for each Dat
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="inputs"></param>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static void InitMiss(List<string> inputs)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.User("This feature is not yet implemented: miss");
|
2016-09-08 17:42:53 -07:00
|
|
|
|
|
|
|
|
|
|
// Verify the filenames
|
|
|
|
|
|
Dictionary<string, string> foundDats = GetValidDats(inputs);
|
2016-09-08 17:52:02 -07:00
|
|
|
|
|
|
|
|
|
|
// Once we have each DAT, look up each associated hash based on the hash of the DATs.
|
|
|
|
|
|
// Then, for each rom, check to see if they exist in the folder. If they do, add it
|
|
|
|
|
|
// to the have DAT, else wise go to the miss DAT. Then output both when the DAT is done
|
|
|
|
|
|
// processing, moving on to the next...
|
|
|
|
|
|
// NOTE: This might share code with InitFixdat
|
2016-09-02 13:59:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|