mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[RombaSharp, Utilities] Implement DatStats for RombaSharp
This commit is contained in:
@@ -64,13 +64,7 @@ namespace RombaSharp
|
|||||||
{
|
{
|
||||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
||||||
df.PopulateFromDir(dir, Hash.DeepHashes, false, false, SkipFileType.None, false, false, _tmpdir, false, null, true);
|
df.PopulateFromDir(dir, Hash.DeepHashes, false, false, SkipFileType.None, false, false, _tmpdir, false, null, true);
|
||||||
|
df.PopulateFromDir(dir, Hash.DeepHashes, false, true, SkipFileType.None, false, false, _tmpdir, false, null, true);
|
||||||
// If we're looking for only needed, consider the zipfiles themselves too
|
|
||||||
if (onlyNeeded)
|
|
||||||
{
|
|
||||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
|
||||||
df.PopulateFromDir(dir, Hash.DeepHashes, false, true, SkipFileType.None, false, false, _tmpdir, false, null, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an empty Dat for files that need to be rebuilt
|
// Create an empty Dat for files that need to be rebuilt
|
||||||
@@ -266,10 +260,17 @@ namespace RombaSharp
|
|||||||
/// Wrap printing dat stats
|
/// Wrap printing dat stats
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inputs">List of input DATs to get stats from</param>
|
/// <param name="inputs">List of input DATs to get stats from</param>
|
||||||
/// TODO: Verify implementation
|
|
||||||
private static void InitDatStats(List<string> inputs)
|
private static void InitDatStats(List<string> inputs)
|
||||||
{
|
{
|
||||||
Globals.Logger.Error("This feature is not yet implemented: datstats");
|
// If we have no inputs listed, we want to use datroot
|
||||||
|
if (inputs == null || inputs.Count == 0)
|
||||||
|
{
|
||||||
|
inputs = new List<string>();
|
||||||
|
inputs.Add(Path.GetFullPath(_dats));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now output the stats for all inputs
|
||||||
|
DatFile.OutputStats(inputs, "rombasharp-datstats", null /* outDir */, true /* single */, true /* baddumpCol */, true /* nodumpCol */, StatReportFormat.Textfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1426,6 +1426,29 @@ namespace SabreTools.Library.Tools
|
|||||||
return infiles;
|
return infiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve a list of directories from a directory recursively in proper order
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directory">Directory to parse</param>
|
||||||
|
/// <param name="infiles">List representing existing files</param>
|
||||||
|
/// <returns>List with all new files</returns>
|
||||||
|
public static List<string> RetrieveDirectories(string directory, List<string> infiles)
|
||||||
|
{
|
||||||
|
// Take care of the files in the top directory
|
||||||
|
List<string> toadd = Directory.EnumerateDirectories(directory, "*", SearchOption.TopDirectoryOnly).ToList();
|
||||||
|
toadd.Sort(new NaturalComparer());
|
||||||
|
infiles.AddRange(toadd);
|
||||||
|
|
||||||
|
// Then recurse through and add from the directories
|
||||||
|
foreach (string dir in toadd)
|
||||||
|
{
|
||||||
|
infiles = RetrieveDirectories(dir, infiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the new list
|
||||||
|
return infiles;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region File Manipulation
|
#region File Manipulation
|
||||||
@@ -1598,6 +1621,41 @@ namespace SabreTools.Library.Tools
|
|||||||
return outputs;
|
return outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve a list of just directories from inputs
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputs">List of strings representing directories and files</param>
|
||||||
|
/// <param name="appendparent">True if the parent name should be appended after the special character "¬", false otherwise (default)</param>
|
||||||
|
/// <returns>List of strings representing just directories from the inputs</returns>
|
||||||
|
public static List<string> GetOnlyDirectoriesFromInputs(List<string> inputs, bool appendparent = false)
|
||||||
|
{
|
||||||
|
List<string> outputs = new List<string>();
|
||||||
|
foreach (string input in inputs)
|
||||||
|
{
|
||||||
|
if (Directory.Exists(input))
|
||||||
|
{
|
||||||
|
List<string> directories = RetrieveDirectories(input, new List<string>());
|
||||||
|
foreach (string dir in directories)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
outputs.Add(Path.GetFullPath(dir) + (appendparent ? "¬" + Path.GetFullPath(input) : ""));
|
||||||
|
}
|
||||||
|
catch (PathTooLongException)
|
||||||
|
{
|
||||||
|
Globals.Logger.Warning("The path for '{0}' was too long", dir);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Globals.Logger.Error(ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputs;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the XmlTextReader associated with a file, if possible
|
/// Get the XmlTextReader associated with a file, if possible
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user