Пример #1
0
 public int GetStream(uint index, out ISequentialOutStream outStream, AskMode askExtractMode)
 {
     if ((index == this.FileNumber) && (askExtractMode == AskMode.kExtract))
     {
         string directoryName = Path.GetDirectoryName(this.FileName);
         if (!string.IsNullOrEmpty(directoryName))
         {
             Directory.CreateDirectory(directoryName);
         }
         if (compressedArchiveOperator.outFileSet == "")
         {
             MessageBox.Show("Fatal Error: No outfile was sent for extraction");
         }
         if (compressedArchiveOperator.fileInRar.Replace('\\', '+') != compressedArchiveOperator.fileInRar)
         {
             compressedArchiveOperator.fileInRar = compressedArchiveOperator.fileInRar.Substring(compressedArchiveOperator.fileInRar.LastIndexOf('\\'), compressedArchiveOperator.fileInRar.Length - compressedArchiveOperator.fileInRar.LastIndexOf('\\'));
         }
         if (compressedArchiveOperator.fileInRar.Replace('/', '+') != compressedArchiveOperator.fileInRar)
         {
             compressedArchiveOperator.fileInRar = compressedArchiveOperator.fileInRar.Substring(compressedArchiveOperator.fileInRar.LastIndexOf('/'), compressedArchiveOperator.fileInRar.Length - compressedArchiveOperator.fileInRar.LastIndexOf('/'));
         }
         compressedArchiveOperator.fileInRar = Program.form.longFileName(compressedArchiveOperator.fileInRar, compressedArchiveOperator.outFileSet.Length);
         if (this.FileStream != null)
         {
             this.FileStream.Dispose();
             this.FileStream = null;
         }
         this.FileStream = new OutStreamWrapper(System.IO.File.Create(compressedArchiveOperator.outFileSet + compressedArchiveOperator.fileInRar));
         outStream       = this.FileStream;
     }
     else
     {
         outStream = null;
     }
     return(0);
 }
Пример #2
0
        public void Pack(string archiveName, ICollection <string> filePathList, string arcType, ProgressBar progress, Label status, bool delete)
        {
            Program.form.waitForFreeMemory(status);
            string outPutFolder = "";

            if (archiveName.Replace('/', '+') != archiveName)
            {
                outPutFolder = archiveName.Substring(0, archiveName.LastIndexOf('/') + 1);
            }
            else
            {
                outPutFolder = archiveName.Substring(0, archiveName.LastIndexOf('\\') + 1);
            }
            creating_archive    = Program.form.origFileLocToNewFileName(archiveName, false, false, outPutFolder);
            attachedProgressBar = progress;
            attachedStatus      = status;
            KnownSevenZipFormat format = this.stringToSevenZipFormat(arcType);

            using (SevenZipFormat format2 = new SevenZipFormat(SevenZipDllPath))
            {
                this.ArchiveOut = format2.CreateOutArchive(SevenZipFormat.GetClassIdFromKnownFormat(format));
                if (this.ArchiveOut == null)
                {
                    showError("-0100\n\n" + format);
                    creating_archive = "";
                    return;
                }
                List <FileInfo> list = new List <FileInfo>(filePathList.Count);
                foreach (string str2 in filePathList)
                {
                    list.Add(new FileInfo(str2));
                }
                try
                {
                    using (OutStreamWrapper wrapper = new OutStreamWrapper(System.IO.File.OpenWrite(archiveName)))
                    {
                        this.ArchiveOut.UpdateItems(wrapper, list.Count, new ArchiveUpdateCallback(list));
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(this.ArchiveOut);
                }
                if (delete)
                {
                    foreach (string str3 in filePathList)
                    {
                        status.Text = "Waiting for " + Program.form.origFileLocToNewFileName(str3, false, false, "") + " to be released";
                        Application.DoEvents();
                        Label_0187 :;
                        try
                        {
                            System.IO.File.Delete(str3);
                        }
                        catch
                        {
                            goto Label_0187;
                        }
                    }
                }
            }
            creating_archive = "";
            Program.form.waitForFreeMemory(status);
        }