diff --git a/SabreTools.Helper/Tools/ArchiveTools.cs b/SabreTools.Helper/Tools/ArchiveTools.cs
index 8f96ade7..49228dbd 100644
--- a/SabreTools.Helper/Tools/ArchiveTools.cs
+++ b/SabreTools.Helper/Tools/ArchiveTools.cs
@@ -607,6 +607,99 @@ namespace SabreTools.Helper.Tools
return roms;
}
+ ///
+ /// Generate a list of empty folders in an archive
+ ///
+ /// Input file to get data from
+ /// List of empty folders in the archive
+ public static List GetEmptyFoldersInArchive(string input)
+ {
+ List empties = new List();
+ string gamename = Path.GetFileNameWithoutExtension(input);
+
+ // First, we check that there is anything being passed as the input
+ if (String.IsNullOrEmpty(input))
+ {
+ return empties;
+ }
+
+ // Next, get the archive type
+ ArchiveType? at = GetCurrentArchiveType(input);
+
+ // If we got back null, then it's not an archive, so we we return
+ if (at == null)
+ {
+ return empties;
+ }
+
+ IReader reader = null;
+ try
+ {
+ Globals.Logger.Verbose("Found archive of type: " + at);
+
+ switch (at)
+ {
+ case ArchiveType.SevenZip:
+ SevenZipArchive sza = SevenZipArchive.Open(input, new ReaderOptions { LeaveStreamOpen = false });
+ foreach (SevenZipArchiveEntry entry in sza.Entries)
+ {
+ if (entry != null && entry.IsDirectory && entry.Size == 0)
+ {
+ empties.Add(entry.Key);
+ }
+ }
+ break;
+
+ case ArchiveType.GZip:
+ // GZip files don't contain directories
+ break;
+
+ case ArchiveType.Rar:
+ RarArchive ra = RarArchive.Open(input, new ReaderOptions { LeaveStreamOpen = false });
+ foreach (RarArchiveEntry entry in ra.Entries)
+ {
+ if (entry != null && entry.IsDirectory && entry.Size == 0)
+ {
+ empties.Add(entry.Key);
+ }
+ }
+ break;
+
+ case ArchiveType.Tar:
+ TarArchive ta = TarArchive.Open(input, new ReaderOptions { LeaveStreamOpen = false });
+ foreach (TarArchiveEntry entry in ta.Entries)
+ {
+ if (entry != null && entry.IsDirectory && entry.Size == 0)
+ {
+ empties.Add(entry.Key);
+ }
+ }
+ break;
+
+ case ArchiveType.Zip:
+ SharpCompress.Archives.Zip.ZipArchive za = SharpCompress.Archives.Zip.ZipArchive.Open(input, new ReaderOptions { LeaveStreamOpen = false });
+ foreach (SharpCompress.Archives.Zip.ZipArchiveEntry entry in za.Entries)
+ {
+ if (entry != null && entry.IsDirectory && entry.Size == 0)
+ {
+ empties.Add(entry.Key);
+ }
+ }
+ break;
+ }
+ }
+ catch (Exception ex)
+ {
+ Globals.Logger.Error(ex.ToString());
+ }
+ finally
+ {
+ reader?.Dispose();
+ }
+
+ return empties;
+ }
+
///
/// Generate a list of RomData objects from the header values in an archive
///