/// <summary>
        /// Extracts a file, a list of file or search + extract a file in case of a string
        /// </summary>
        public void Extract(object obj)
        {
            boList            = new BufferObjectList();
            numExtractedFiles = 0;
            List <FileInArchive> fileList = new List <FileInArchive>();

            if (obj.GetType() == typeof(List <FileInArchive>))
            {
                fileList = (List <FileInArchive>)obj;
            }
            else if (obj.GetType() == typeof(FileInArchive))
            {
                fileList.Add((FileInArchive)obj);
            }
            else if (obj.GetType() == typeof(string))
            {
                FileInArchive tmpFIA = this.SearchForFile((string)obj);
                if (tmpFIA == null)
                {
                    return;
                }
                fileList.Add(tmpFIA);
            }
            numOfFileInExtractionList = fileList.Count; //needed since the events are launched in the save buffer now

            //If we are using more than one disk, then we multi thread
            //Otherwise having 2 threads doing the reading and the writting is bad
            if (mypPath[0] == extractionPath[0])
            {
                MypHandlerConfig.MultithreadedExtraction = false;
            }

            if (MypHandlerConfig.MultithreadedExtraction)
            {
                boList.Active = true;
                Thread t_BOwriter = new Thread(new ThreadStart(ThreadWrite));
                t_BOwriter.Start();
                //Multi threading the writes is useless even when we have lots of small files.
                //Thread t_BOwriter2 = new Thread(new ThreadStart(ThreadWrite));
                //t_BOwriter2.Start();
            }

            for (int i = 0; i < fileList.Count; i++)
            {
                ExtractFile(fileList[i]);
            }

            if (!MypHandlerConfig.MultithreadedExtraction)
            {
                TriggerExtractionEvent(new MYPFileEventArgs(Event_ExtractionType.ExtractionFinished, fileList.Count - error_ExtractionNumber));
            }
            else
            {
                boList.Active = false;
            }
        }
示例#2
0
        public void Extract(object obj)
        {
            this.boList            = new BufferObjectList();
            this.numExtractedFiles = 0L;
            List <FileInArchive> fileInArchiveList = new List <FileInArchive>();

            if (obj.GetType() == typeof(List <FileInArchive>))
            {
                fileInArchiveList = (List <FileInArchive>)obj;
            }
            else if (obj.GetType() == typeof(FileInArchive))
            {
                fileInArchiveList.Add((FileInArchive)obj);
            }
            else if (obj.GetType() == typeof(string))
            {
                FileInArchive fileInArchive = this.SearchForFile((string)obj);
                if (fileInArchive == null)
                {
                    return;
                }
                fileInArchiveList.Add(fileInArchive);
            }
            this.numOfFileInExtractionList = fileInArchiveList.Count;
            if ((int)this.mypPath[0] == (int)this.extractionPath[0])
            {
                MypHandlerConfig.MultithreadedExtraction = false;
            }
            if (MypHandlerConfig.MultithreadedExtraction)
            {
                this.boList.Active = true;
                new Thread(new ThreadStart(this.ThreadWrite)).Start();
            }
            for (int index = 0; index < fileInArchiveList.Count; ++index)
            {
                this.ExtractFile(fileInArchiveList[index]);
            }
            if (!MypHandlerConfig.MultithreadedExtraction)
            {
                this.TriggerExtractionEvent(new MYPFileEventArgs(Event_ExtractionType.ExtractionFinished, (long)fileInArchiveList.Count - this.error_ExtractionNumber));
            }
            else
            {
                this.boList.Active = false;
            }
        }
示例#3
0
        /// <summary>
        /// Extracts a file, a list of file or search + extract a file in case of a string
        /// </summary>
        public void Extract(object obj)
        {
            boList = new BufferObjectList();
            numExtractedFiles = 0;
            List<FileInArchive> fileList = new List<FileInArchive>();
            if (obj.GetType() == typeof(List<FileInArchive>))
            {
                fileList = (List<FileInArchive>)obj;
            }
            else if (obj.GetType() == typeof(FileInArchive))
            {
                fileList.Add((FileInArchive)obj);
            }
            else if (obj.GetType() == typeof(string))
            {
                FileInArchive tmpFIA = this.SearchForFile((string)obj);
                if (tmpFIA == null)
                {
                    return;
                }
                fileList.Add(tmpFIA);
            }
            numOfFileInExtractionList = fileList.Count; //needed since the events are launched in the save buffer now

            //If we are using more than one disk, then we multi thread
            //Otherwise having 2 threads doing the reading and the writting is bad
            if (mypPath[0] == extractionPath[0])
            {
                MypHandlerConfig.MultithreadedExtraction = false;
            }

            if (MypHandlerConfig.MultithreadedExtraction)
            {
                boList.Active = true;
                Thread t_BOwriter = new Thread(new ThreadStart(ThreadWrite));
                t_BOwriter.Start();
                //Multi threading the writes is useless even when we have lots of small files.
                //Thread t_BOwriter2 = new Thread(new ThreadStart(ThreadWrite));
                //t_BOwriter2.Start();
            }

            for (int i = 0; i < fileList.Count; i++)
            {
                ExtractFile(fileList[i]);
            }

            if (!MypHandlerConfig.MultithreadedExtraction)
            {
                TriggerExtractionEvent(new MYPFileEventArgs(Event_ExtractionType.ExtractionFinished, fileList.Count - error_ExtractionNumber));
            }
            else
            {
                boList.Active = false;
            }
        }