/// <summary> /// Generate a list of empty folders in an archive /// </summary> /// <param name="input">Input file to get data from</param> /// <returns>List of empty folders in the archive</returns> public override List <string> GetEmptyFolders() { List <string> empties = new List <string>(); try { SharpCompress.Archives.Rar.RarArchive ra = SharpCompress.Archives.Rar.RarArchive.Open(_filename, new ReaderOptions { LeaveStreamOpen = false }); List <RarArchiveEntry> rarEntries = ra.Entries.OrderBy(e => e.Key, new NaturalSort.NaturalReversedComparer()).ToList(); string lastRarEntry = null; foreach (RarArchiveEntry entry in rarEntries) { if (entry != null) { // If the current is a superset of last, we skip it if (lastRarEntry != null && lastRarEntry.StartsWith(entry.Key)) { // No-op } // If the entry is a directory, we add it else if (entry.IsDirectory) { empties.Add(entry.Key); lastRarEntry = entry.Key; } } } } catch (Exception ex) { Globals.Logger.Error(ex.ToString()); } return(empties); }
/// <summary> /// RarArchive is the first volume of a multi-part archive. If MultipartVolume is true and IsFirstVolume is false then the first volume file must be missing. /// </summary> public static bool IsFirstVolume(this RarArchive archive) { return(archive.Volumes.First().IsFirstVolume); }
internal RarArchiveEntry(RarArchive archive, IEnumerable <RarFilePart> parts) { this.parts = parts.ToList(); this.archive = archive; }
internal RarArchiveEntry(RarArchive archive, IEnumerable <RarFilePart> parts, ReaderOptions readerOptions) { this.parts = parts.ToList(); this.archive = archive; this.readerOptions = readerOptions; }