Beispiel #1
0
        private void ProcessDirectory(IFileObject directory, bool includeSubDirs)
        {
            IFileObject[] files = directory.findFiles(Selectors.SELECT_CHILDREN);
            if (files == null)
            {
                return;
            }

            foreach (IFileObject file in files)
            {
                if (this.excludeList.ContainsKey(file.Name.URI))
                {
                    continue;
                }

                if (file.Type == FileType.FILE)
                {
                    IFileName name = file.Name;
                    string extension = name.Extension;

                    switch (extension)
                    {
                        case "fb2":
                            ImportFileEntry entry = new ImportFileEntry(chkSelectFoundFiles.Checked, name.BaseName, name.URI);
                            entry.Status = ImportStatus.ReadyToProcess;

                            if (entry.Selected)
                            {
                                this.processLegend.IncrementCounter(ImportStatus.ReadyToProcess);
                                this.grdLegend.RefreshDataSource();
                            }

                            this.fileEntries.Add(entry);
                            this.excludeList.Add(file.Name.URI, entry);
                            break;

                        case "zip":
                            String url = "zip:" + name.URI + "!/";

                            //string filename = Path.ChangeExtension(name.BaseName, null);
                            //if(String.Compare(Path.GetExtension(filename), ".fb2", true) == 0)
                            //{
                            //    if (this.excludeList.ContainsKey(url + filename))
                            //    {
                            //        continue;
                            //    }

                            //    entry = new ImportFileEntry(chkSelectFoundFiles.Checked, filename, url + filename);
                            //    entry.Status = ImportStatus.ReadyToProcess;

                            //    if (entry.Selected)
                            //    {
                            //        this.processLegend.IncrementCounter(ImportStatus.ReadyToProcess);
                            //        this.grdLegend.RefreshDataSource();
                            //    }

                            //    this.fileEntries.Add(entry);
                            //    this.excludeList.Add(entry.Uri, entry);
                            //    break;

                            //}

                            IFileObject zipFile = manager.resolveFile(url);
                            ProcessDirectory(zipFile, true);
                            break;

                        case "7z":
                            IFileObject sevenZipFile = manager.resolveFile("sevenzip:" + name.URI + "!/");
                            ProcessDirectory(sevenZipFile, true);
                            break;

                        case "rar":
                            IFileObject rarFile = manager.resolveFile("rar:" + name.URI + "!/");
                            ProcessDirectory(rarFile, true);
                            break;
                    }
                }
                else if (file.Type == FileType.FOLDER && includeSubDirs)
                {
                    ProcessDirectory(file, true);
                }
            }
        }