internal static FileInfo GetFilePart(int index, FileInfo part1) //base the name on the first part { FileInfo item = null; //new style rar - ..part1 | /part01 | part001 .... Match m = Regex.Match(part1.Name, @"^(.*\.part)([0-9]+)(\.rar)$", RegexOptions.IgnoreCase); if (m.Success) { item = new FileInfo(Path.Combine(part1.DirectoryName, String.Concat(m.Groups[1].Value, (index + 1).ToString().PadLeft(m.Groups[2].Value.Length, '0'), m.Groups[3].Value))); } else { //old style - ...rar, .r00, .r01 ... m = Regex.Match(part1.Name, @"^(.*\.r)(ar|[0-9]+)$", RegexOptions.IgnoreCase); if (m.Success) { item = new FileInfo(Path.Combine(part1.DirectoryName, String.Concat(m.Groups[1].Value, index == 0 ? "ar" : (index - 1).ToString().PadLeft(m.Groups[2].Value.Length, '0')))); } else //split .001, .002 .... { return(ArchiveVolumeFactory.GetFilePart(index, part1)); } } if (item != null && item.Exists) { return(item); } return(null); //no more items }
internal static FileInfo GetFilePart(int index, FileInfo part1) //base the name on the first part { FileInfo item = null; //load files with zip/zipx first. Swapped to end once loaded in ZipArchive //new style .zip, z01.. | .zipx, zx01 - if the numbers go beyond 99 then they use 100 ...1000 etc Match m = Regex.Match(part1.Name, @"^(.*\.)(zipx?|zx?[0-9]+)$", RegexOptions.IgnoreCase); if (m.Success) { item = new FileInfo(Path.Combine(part1.DirectoryName, String.Concat(m.Groups[1].Value, Regex.Replace(m.Groups[2].Value, @"[^xz]", ""), index.ToString().PadLeft(2, '0')))); } else //split - 001, 002 ... { return(ArchiveVolumeFactory.GetFilePart(index, part1)); } if (item != null && item.Exists) { return(item); } return(null); //no more items }
public static SevenZipArchive Open(FileInfo fileInfo, ReaderOptions readerOptions = null) { fileInfo.CheckNotNull("fileInfo"); return(new SevenZipArchive(new SourceStream(fileInfo, i => ArchiveVolumeFactory.GetFilePart(i, fileInfo), readerOptions ?? new ReaderOptions()))); }
/// <summary> /// Constructor with a FileInfo object to an existing file. /// </summary> /// <param name="fileInfo"></param> /// <param name="readerOptions"></param> public static TarArchive Open(FileInfo fileInfo, ReaderOptions?readerOptions = null) { fileInfo.CheckNotNull(nameof(fileInfo)); return(new TarArchive(new SourceStream(fileInfo, i => ArchiveVolumeFactory.GetFilePart(i, fileInfo), readerOptions ?? new ReaderOptions()))); }