Browse Source

【UI替换】编辑工具 - 合并 功能串接

lizhe 1 year ago
parent
commit
6a0d89e680

+ 201 - 2
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/KMMergeWindowController.swift

@@ -63,8 +63,8 @@ class KMMergeWindowController: NSWindowController {
             
         }
         
-        mergeView.mergeAction = { [unowned self] view in
-            
+        mergeView.mergeAction = { [unowned self] view, files, size in
+            self.mergeFiles(files: files, size: size)
         }
         
         mergeView.cancelAction = { [unowned self] view in
@@ -136,4 +136,203 @@ extension KMMergeWindowController {
         }
 
     }
+    
+    func mergeFiles(files: [KMFileAttribute], size: CGSize = CGSizeZero) {
+        if files.count <= 1 {
+            let alert = NSAlert.init()
+            alert.alertStyle = .critical
+            alert.messageText = NSLocalizedString("To start merging, please select at least 2 files.", comment: "")
+            alert.runModal()
+            return
+        }
+        
+//        _isSuccessfully = NO;
+//        [self.nCancelVC setEnabled:NO];
+//        self.canMerge = NO;
+//        
+        var rootPDFOutlineArray: [PDFOutline] = []
+        var allPage = true //只有是全部才支持大纲的合并
+        for file in files {
+            if file.fetchSelectPages().count == 0 {
+                let alert = NSAlert.init()
+                alert.alertStyle = .critical
+                alert.messageText = "\(file.filePath.lastPathComponent) + \(NSLocalizedString("Invalid page range or the page number is out of range. Please try again.", comment: ""))"
+                alert.runModal()
+                return
+            }
+            
+            allPage = file.bAllPage
+            
+            let tDocument = PDFDocument(url: NSURL(fileURLWithPath: file.filePath) as URL)!
+            
+            var outlineArray: [PDFOutline] = []
+            
+            if file.isLocked {
+                tDocument.unlock(withPassword: file.password!)
+            }
+            
+            if tDocument.outlineRoot != nil {
+                rootPDFOutlineArray.append((tDocument.outlineRoot)!)
+                self.fetchAllOfChildren((tDocument.outlineRoot)!, containerArray: &outlineArray)
+                outlineArray.removeObject((tDocument.outlineRoot)!)
+            } else {
+                let rootOutline = PDFOutline.init()
+                tDocument.outlineRoot = rootOutline
+                if tDocument.outlineRoot != nil {
+                    rootPDFOutlineArray.append(tDocument.outlineRoot!)
+                }
+            }
+            
+            for number in file.fetchSelectPages() {
+                let page = tDocument.page(at: number.intValue - 1)
+                self.pdfDocument.insert(page!, at: self.pdfDocument.pageCount)
+//                self.insertIndexSet.addIndex:(self.pdfDocument.pageCount - 1)
+            }
+        }
+        
+        
+        let fileName = (files.first?.filePath.lastPathComponent)! + "_Merged"
+        DispatchQueue.main.async {
+            self.pdfDocument.outlineRoot = PDFOutline.init()
+            if allPage {
+                var insertIndex = 0
+                for i in 0..<rootPDFOutlineArray.count {
+                    let rootOutline = rootPDFOutlineArray[i]
+                    for j in 0..<rootOutline.numberOfChildren {
+                        self.pdfDocument.outlineRoot?.insertChild(rootOutline.child(at: j)!, at: insertIndex)
+                    }
+                    insertIndex = insertIndex + 1
+                }
+                
+                self.handleReDraw()
+                
+                let savePanelAccessoryViewController = KMSavePanelAccessoryController.init()
+                let savePanel = NSSavePanel()
+                savePanel.nameFieldStringValue = fileName
+                savePanel.allowedFileTypes = ["pdf"]
+                savePanel.accessoryView = savePanelAccessoryViewController.view
+//                self.savePanelAccessoryViewController = savePanelAccessoryViewController;
+                savePanel.beginSheetModal(for: self.window!) { result in
+                    if result != nil {
+                        var outputSavePanel = savePanel.url?.path
+                        DispatchQueue.main.async {
+                            var success = self.pdfDocument.write(toFile: outputSavePanel!)
+                            if !success {
+                                success = ((try?self.pdfDocument.dataRepresentation()?.write(to: URL(string: outputSavePanel!)!)) != nil)
+                            }
+                            
+                            if success {
+                                if savePanelAccessoryViewController.needOpen {
+                                    NSDocumentController.shared.openDocument(withContentsOf: savePanel.url!, display: true) { document, open, error in
+                                        
+                                    }
+                                } else {
+                                    NSWorkspace.shared.activateFileViewerSelecting([NSURL(fileURLWithPath: outputSavePanel!) as URL])
+                                }
+                            } else {
+                                let alert = NSAlert.init()
+                                alert.alertStyle = .critical
+                                alert.messageText = "\(String(describing: files.first?.filePath.lastPathComponent)) + \(NSLocalizedString("Failed to merge!", comment: ""))"
+                                alert.runModal()
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    
+    func fetchAllOfChildren(_ aOutline: PDFOutline, containerArray aMArray: inout [PDFOutline]) {
+        if !aMArray.contains(aOutline) {
+            aMArray.append(aOutline)
+        }
+        
+        for i in 0..<aOutline.numberOfChildren {
+            if let childOutline = aOutline.child(at: i) {
+                aMArray.append(childOutline)
+                fetchAllOfChildren(childOutline, containerArray: &aMArray)
+            }
+        }
+    }
+    
+    func handleReDraw() {
+        if mergeView.originalSizeButton.state == .on {
+            
+        } else {
+            let size = self.mergeView.newPageSize
+            if size.width < 0 {
+                return
+            }
+            
+            var pagesArray: [PDFPage] = []
+            let pageCount = self.pdfDocument.pageCount
+            for i in 0..<pageCount {
+                pagesArray.append(self.pdfDocument.page(at: i)!)
+                self.pdfDocument.removePage(at: 0)
+            }
+            
+            for i in 0..<pageCount {
+                let page: KMMergePDFPage = KMMergePDFPage.init()
+                page.setBounds(CGRectMake(0, 0, size.width, size.height), for: .mediaBox)
+                page.drawingPage = pagesArray[i]
+                self.pdfDocument.insert(page, at: i)
+            }
+            
+            if self.pdfDocument.outlineRoot != nil {
+                let childCount = self.pdfDocument.outlineRoot?.numberOfChildren
+                var outlineArray: [PDFOutline] = []
+                
+                for i in 0..<childCount! {
+                    outlineArray.append((self.pdfDocument.outlineRoot?.child(at: i))!)
+                }
+                
+                for outline in outlineArray {
+                    outline.removeFromParent()
+                }
+            }
+        }
+    }
+}
+
+class KMMergePDFPage: PDFPage {
+    var drawingPage: PDFPage?
+    
+    override func draw(with box: PDFDisplayBox, to context: CGContext) {
+        super.draw(with: box, to: context)
+        
+        let pageSize = self.bounds(for: .cropBox).size
+        self.drawPage(with: context, page: self.drawingPage!, pageSize: pageSize)
+    }
+    
+    func drawPage(with context: CGContext, page: PDFPage, pageSize: CGSize) {
+        var originalSize = page.bounds(for: .cropBox).size
+        
+        // 如果页面的旋转角度为90或者270,宽高交换
+        if page.rotation % 180 != 0 {
+            originalSize = CGSize(width: originalSize.height, height: originalSize.width)
+        }
+        
+        let wRatio = pageSize.width / originalSize.width
+        let hRatio = pageSize.height / originalSize.height
+        let ratio = min(wRatio, hRatio)
+        
+        context.saveGState()
+        let xTransform = (pageSize.width - originalSize.width * ratio) / 2
+        let yTransform = (pageSize.height - originalSize.height * ratio) / 2
+        context.translateBy(x: xTransform, y: yTransform)
+        context.scaleBy(x: ratio, y: ratio)
+        
+        if #available(macOS 10.12, *) {
+            page.draw(with: .cropBox, to: context)
+            page.transformContext(for: .cropBox)
+        } else {
+            NSGraphicsContext.saveGraphicsState()
+            NSGraphicsContext.current = NSGraphicsContext(cgContext: context, flipped: false)
+            page.draw(with: .cropBox)
+            NSGraphicsContext.restoreGraphicsState()
+            page.transformContext(for: .cropBox)
+        }
+        
+        context.restoreGState()
+    }
 }

+ 9 - 9
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeTableViewCell.xib

@@ -25,7 +25,7 @@
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <button translatesAutoresizingMaskIntoConstraints="NO" id="auJ-Ql-T1u">
-                    <rect key="frame" x="418" y="84" width="16" height="16"/>
+                    <rect key="frame" x="418" y="94" width="16" height="16"/>
                     <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="KMImageNameUXIconBtnCloseNor" imagePosition="only" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="1Rg-kr-6Uo">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
@@ -50,14 +50,14 @@
                     </textFieldCell>
                 </textField>
                 <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="na2-lK-ZzE">
-                    <rect key="frame" x="50" y="10" width="80" height="90"/>
+                    <rect key="frame" x="50" y="10" width="90" height="100"/>
                     <constraints>
-                        <constraint firstAttribute="width" constant="80" id="V0y-6x-MDn"/>
+                        <constraint firstAttribute="width" constant="90" id="V0y-6x-MDn"/>
                     </constraints>
                     <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSAdvanced" id="qqK-8T-lwg"/>
                 </imageView>
                 <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2eO-De-B2W">
-                    <rect key="frame" x="138" y="84" width="85" height="16"/>
+                    <rect key="frame" x="148" y="94" width="85" height="16"/>
                     <textFieldCell key="cell" lineBreakMode="truncatingMiddle" sendsActionOnEndEditing="YES" title="FileName.pdf" id="Bg6-cL-pdM">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -65,7 +65,7 @@
                     </textFieldCell>
                 </textField>
                 <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3qa-uf-Mow">
-                    <rect key="frame" x="138" y="64" width="39" height="16"/>
+                    <rect key="frame" x="148" y="74" width="39" height="16"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="2.0M" id="evW-Xd-b1j">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="systemGrayColor" catalog="System" colorSpace="catalog"/>
@@ -73,7 +73,7 @@
                     </textFieldCell>
                 </textField>
                 <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YEO-oA-Pcm">
-                    <rect key="frame" x="139" y="11" width="290" height="23"/>
+                    <rect key="frame" x="149" y="21" width="280" height="23"/>
                     <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="xw7-eG-mEz">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -89,7 +89,7 @@
                     </connections>
                 </comboBox>
                 <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="SY0-cA-yGR">
-                    <rect key="frame" x="203" y="64" width="61" height="16"/>
+                    <rect key="frame" x="213" y="74" width="61" height="16"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="23 Pages" id="uTx-ug-Fkm">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="systemGrayColor" catalog="System" colorSpace="catalog"/>
@@ -97,7 +97,7 @@
                     </textFieldCell>
                 </textField>
                 <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="i9L-3z-H54">
-                    <rect key="frame" x="138" y="38" width="77" height="16"/>
+                    <rect key="frame" x="148" y="48" width="77" height="16"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Page Range" id="WiQ-g6-mnQ">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -121,7 +121,7 @@
                 <constraint firstItem="jno-5q-97T" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="e26-MQ-5x7"/>
                 <constraint firstItem="YEO-oA-Pcm" firstAttribute="top" secondItem="i9L-3z-H54" secondAttribute="bottom" constant="5" id="fCh-0s-XcL"/>
                 <constraint firstItem="SY0-cA-yGR" firstAttribute="leading" secondItem="3qa-uf-Mow" secondAttribute="trailing" constant="30" id="gI1-dn-uUu"/>
-                <constraint firstItem="na2-lK-ZzE" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="20" id="i19-B2-kAD"/>
+                <constraint firstItem="na2-lK-ZzE" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="oEh-dF-J8S"/>
                 <constraint firstItem="jno-5q-97T" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="20" id="qAP-J0-9lh"/>
                 <constraint firstItem="3qa-uf-Mow" firstAttribute="top" secondItem="2eO-De-B2W" secondAttribute="bottom" constant="4" id="rgI-TX-fAy"/>
                 <constraint firstItem="i9L-3z-H54" firstAttribute="leading" secondItem="3qa-uf-Mow" secondAttribute="leading" id="vKT-z4-fW2"/>

+ 94 - 83
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.swift

@@ -9,7 +9,7 @@ import Cocoa
 
 typealias KMMergeViewCancelAction = (_ view: KMMergeView) -> Void
 typealias KMMergeViewAddFilesAction = (_ view: KMMergeView) -> Void
-typealias KMMergeViewMergeAction = (_ view: KMMergeView) -> Void
+typealias KMMergeViewMergeAction = (_ view: KMMergeView, _ files: [KMFileAttribute], _ size: CGSize) -> Void
 typealias KMMergeViewClearAction = (_ view: KMMergeView) -> Void
 
 class KMMergeView: KMBaseXibView {
@@ -67,6 +67,7 @@ class KMMergeView: KMBaseXibView {
         tableview.delegate = self
         tableview.dataSource = self
         tableview.allowsMultipleSelection = true
+        tableview.registerForDraggedTypes([MyTableCellViewDataType, .fileURL, .string, .pdf])
         
 //        tableview.register(NSNib.init(nibNamed: "KMMergeTableViewCell", bundle: nil), forIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMMergeTableViewCell"))
         
@@ -114,7 +115,7 @@ class KMMergeView: KMBaseXibView {
     }
     
     func updateButtonState() {
-        if (files.count > 0) {
+        if (files.count > 1) {
             blankView.isHidden = true
             clearButton.isEnabled = true
             mergeButton.isEnabled = true
@@ -145,6 +146,9 @@ extension KMMergeView: NSTableViewDataSource {
             cell = KMMergeTableViewCell.init(frame: CGRectZero)
         }
         let myCellView: KMMergeTableViewCell = cell! as! KMMergeTableViewCell
+        if row < files.count {
+            myCellView.fileModel = files[row]
+        }
         // 配置单元格的显示内容
         myCellView.removeAction = { [unowned self] view, model in
             self.files.removeObject(model)
@@ -159,7 +163,7 @@ extension KMMergeView: NSTableViewDataSource {
     }
     
     func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
-        return 60
+        return 120
     }
 }
 
@@ -180,16 +184,14 @@ extension KMMergeView: NSTableViewDelegate {
         var result = NSDragOperation.copy
         let pboard = info.draggingPasteboard
 
-        if pboard.availableType(from: [NSPasteboard.PasteboardType.fileNameType(forPathExtension: "pdf")]) != nil {
-            if let fileNames = pboard.propertyList(forType: NSPasteboard.PasteboardType.fileNameType(forPathExtension: "pdf")) as? [String] {
-                for path in fileNames {
-                    if path.lowercased().hasSuffix("pdf") {
-                        isCanDrag = true
-                    } else {
-                        isCanDrag = false
-                        break
-                    }
-                }
+        if pboard.availableType(from: [NSPasteboard.PasteboardType.fileURL]) != nil {
+            let filePath = pboard.propertyList(forType: NSPasteboard.PasteboardType.fileURL) as? String
+            let url = URL(string: filePath!)
+                
+            if url!.path.lowercased().hasSuffix("pdf") {
+                isCanDrag = true
+            } else {
+                isCanDrag = false
             }
         } else if (pboard.availableType(from: [MyTableCellViewDataType]) != nil) {
             result = .every
@@ -208,86 +210,86 @@ extension KMMergeView: NSTableViewDelegate {
            insertRow = row
 
 //        NSPasteboard.PasteboardType.fileURL
-           if pboard.availableType(from: [NSPasteboard.PasteboardType.fileNameType(forPathExtension: "pdf")]) != nil {
-               if let fileNames = pboard.propertyList(forType: NSPasteboard.PasteboardType.fileNameType(forPathExtension: "pdf")) as? [String] {
-                   var array = [URL]()
+        if pboard.availableType(from: [NSPasteboard.PasteboardType.fileURL]) != nil {
+            let filePath = pboard.propertyList(forType: NSPasteboard.PasteboardType.fileURL) as? String
+            let url = URL(string: filePath!)
+            var array = [URL]()
+            array.append(url!)
+//               for path in fileNames {
+//                   if !isExistAtFilePath(filePath: path) {
+//                       continue
+//                   }
+////                       if let attrib = try? FileManager.default.attributesOfItem(atPath: path),
+////                          let fileSize = attrib[.size] as? CGFloat {
+////
+////                           allFileSize += fileSize
+////
+////                           if !IAPProductsManager.defaultManager.isAvailableAllFunction {
+////                               // 免费版只支持2个文件做合并,小于20M的文件合并
+////                               if files.count >= 2 || allFileSize > (20 * 1024 * 1024) {
+////                                   let vc = KMToolCompareWindowController.toolCompare(with: .pageEdit, setSelectIndex: 1)
+////                                   vc.showWindow(nil)
+////
+////                                   allFileSize -= fileSize
+////                                   addFiles(array)
+////                                   result = true
+////                                   return false
+////                               }
+////                           }
+//                   array.append(URL(string: path)!)
+////                       }
+//               }
+            addFilePaths(urls: array)
+            result = true
+       } else if pboard.availableType(from: [MyTableCellViewDataType]) != nil {
+           if let rowData = pboard.data(forType: MyTableCellViewDataType),
+              let rowIndexes = NSKeyedUnarchiver.unarchiveObject(with: rowData) as? IndexSet {
 
-                   for path in fileNames {
-                       if !isExistAtFilePath(filePath: path) {
-                           continue
-                       }
-//                       if let attrib = try? FileManager.default.attributesOfItem(atPath: path),
-//                          let fileSize = attrib[.size] as? CGFloat {
-//
-//                           allFileSize += fileSize
-//
-//                           if !IAPProductsManager.defaultManager.isAvailableAllFunction {
-//                               // 免费版只支持2个文件做合并,小于20M的文件合并
-//                               if files.count >= 2 || allFileSize > (20 * 1024 * 1024) {
-//                                   let vc = KMToolCompareWindowController.toolCompare(with: .pageEdit, setSelectIndex: 1)
-//                                   vc.showWindow(nil)
-//
-//                                   allFileSize -= fileSize
-//                                   addFiles(array)
-//                                   result = true
-//                                   return false
-//                               }
-//                           }
-                       array.append(URL(string: path)!)
-//                       }
-                   }
-                   addFilePaths(urls: array)
-                   result = true
+               var moveArray = [KMFileAttribute]()
+               var allPhoto: [KMFileAttribute] = []
+               var index = 0
+               
+               for file in files {
+                   allPhoto.append(file)
                }
-           } else if pboard.availableType(from: [MyTableCellViewDataType]) != nil {
-               if let rowData = pboard.data(forType: MyTableCellViewDataType),
-                  let rowIndexes = NSKeyedUnarchiver.unarchiveObject(with: rowData) as? IndexSet {
-
-                   var moveArray = [KMFileAttribute]()
-                   var allPhoto: [KMFileAttribute] = []
-                   var index = 0
-                   
-                   for file in files {
-                       allPhoto.append(file)
-                   }
 
-                   rowIndexes.enumerated().forEach { (idx, shouldStop) in
-                       moveArray.append(allPhoto[idx])
-                       files.remove(at: idx)
-                   }
-
-                   var newRow = row
-                   if newRow > 0 {
-                       var indexFile: KMFileAttribute?
-
-                       repeat {
-                           newRow = newRow - 1
+               rowIndexes.enumerated().forEach { (idx, shouldStop) in
+                   moveArray.append(allPhoto[idx])
+                   files.remove(at: idx)
+               }
 
-                           guard newRow >= 0 else {
-                               indexFile = nil
-                               break
-                           }
+               var newRow = row
+               if newRow > 0 {
+                   var indexFile: KMFileAttribute?
 
-                           indexFile = allPhoto[row]
-                       } while moveArray.contains(indexFile!)
+                   repeat {
+                       newRow = newRow - 1
 
-                       if let indexFile = indexFile {
-                           index = files.firstIndex(of: indexFile)! + 1
+                       guard newRow >= 0 else {
+                           indexFile = nil
+                           break
                        }
-                   }
 
-                   moveArray.enumerated().forEach { (i, file) in
-                       files.insert(file, at: (index + i))
+                       indexFile = allPhoto[newRow]
+                   } while moveArray.contains(indexFile!)
+
+                   if let indexFile = indexFile {
+                       index = files.firstIndex(of: indexFile)! + 1
                    }
+               }
 
-                   tableView.reloadData()
-                   result = true
+               moveArray.enumerated().forEach { (i, file) in
+                   files.insert(file, at: (index + i))
                }
-           } else {
-               result = false
+
+               tableView.reloadData()
+               result = true
            }
+       } else {
+           result = false
+       }
 
-           return result
+       return result
     }
 }
 
@@ -310,7 +312,7 @@ extension KMMergeView {
     @IBAction func mergeButtonAction(_ sender: Any) {
         guard let callBack = mergeAction else { return }
         
-        callBack(self)
+        callBack(self, self.files, self.newPageSize)
     }
     
     @IBAction func addFilesButtonAction(_ sender: Any) {
@@ -363,7 +365,7 @@ extension KMMergeView {
 extension KMMergeView {
     func addFilePaths(urls: [URL]) {
         lockFiles.removeAll()
-        files.removeAll()
+//        files.removeAll()
         
         for url in urls {
             let file = KMFileAttribute()
@@ -372,7 +374,16 @@ extension KMMergeView {
             if file.isLocked {
                 lockFiles.append(file)
             } else {
-                files.append(file)
+                var isExist = false
+                for item in files {
+                    if item.filePath == file.filePath {
+                        isExist = true
+                        break
+                    }
+                }
+                if !isExist {
+                    files.append(file)
+                }
             }
         }