diff --git a/RombaSharp/RombaSharp.Inits.cs b/RombaSharp/RombaSharp.Inits.cs index 8b8c3e09..e1c233df 100644 --- a/RombaSharp/RombaSharp.Inits.cs +++ b/RombaSharp/RombaSharp.Inits.cs @@ -337,14 +337,34 @@ namespace RombaSharp /// Source directory /// Name value in DAT header /// Description value in DAT header - /// TODO: Implement private static void InitDir2Dat( string outdat, string source, string name, string description) { - Globals.Logger.Error("This feature is not yet implemented: dir2dat"); + // Ensure the output directory + Utilities.EnsureOutputDirectory(outdat, create: true); + + // Check that all required directories exist + if (!Directory.Exists(source)) + { + Globals.Logger.Error("File '{0}' does not exist!", source); + return; + } + + // Create the encapsulating datfile + DatFile datfile = new DatFile() + { + Name = (String.IsNullOrWhiteSpace(name) ? "untitled" : name), + Description = description, + }; + + // Now run the D2D on the input and write out + // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually + datfile.PopulateFromDir(source, Hash.DeepHashes, true /* bare */, false /* archivesAsFiles */, SkipFileType.None, false /* addBlanks */, + false /* addDate */, _tmpdir, false /* copyFiles */, null /* headerToCheckAgainst */, true /* chdsAsFiles */); + datfile.Write(outDir: outdat); } ///