private bool IsValidFirstVolume(RarArchive archive) =>
 archive.IsFirstVolume() && archive.IsComplete && archive.IsMultipartVolume();
Пример #2
0
        protected override void UnpackImpl()
        {
            var firstFile = InputFilePaths.FirstOrDefault(); //*.rar or *.r01

            if (firstFile == null)
            {
                return;
            }

            //Path.GetDirectoryName(firstFile)  ;
            var options = new ExtractionOptions()
            {
                ExtractFullPath = true, Overwrite = true
            };

            using (var archive = ArchiveFactory.Open(firstFile))
            {
                if (archive is RarArchive)
                {
                    RarArchive rar = archive as RarArchive;
                    if (rar.IsMultipartVolume() && !rar.IsFirstVolume())
                    {
                        var path = rar.Volumes.FirstOrDefault();
                        CurrentProgressDescription = "Please Unpack from the 1st volume";
                        OnUnpackFinished(false);
                        return;
                    }
                }
                else //Zip or 7z
                {
                }

                if (!archive.IsComplete)
                {
                    CurrentProgressDescription = "Incomplete files: some files are missing.";
                    OnUnpackFinished(false);
                    return;
                }
                bytesUnpacked = 0;

                archive.EntryExtractionBegin += OnEntryExtractionBegin;
                archive.EntryExtractionEnd   += OnEntryExtractionEnd;
                archive.CompressedBytesRead  += OnBytesRead;

                bool bSingleChildFolderExists = CheckSingleSubFolderExists(archive);
                if (bSingleChildFolderExists)
                {
                    single_child_folder_to_unpack_to = Path.Combine(TargetExtractionFolder, single_child_folder_to_unpack_to);
                }

                bool bShouldExtractHere = bSingleChildFolderExists || archive.Entries.Count() == 1;

                if (!bShouldExtractHere)
                {
                    TargetExtractionFolder = Path.Combine(TargetExtractionFolder, Title);
                }

                foreach (var entry in archive.Entries)
                {
                    if (!entry.IsDirectory)
                    {
                        entry.WriteToDirectory(TargetExtractionFolder, options);
                    }
                }
            }
        }