12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- //
- // ImageToPDFTools.swift
- // PDF Master
- //
- // Created by lizhe on 2023/2/18.
- //
- import Cocoa
- class ImageToPDFTools: NSObject {
- /**
- 获取打开文件
- */
- static func fetchOpenDocumentFiles() -> [URL] {
- var files:[URL] = []
- for window in NSApp.windows {
- if window.windowController is KMBrowserWindowController {
- let controller: KMBrowserWindowController = window.windowController as! KMBrowserWindowController
- if controller.browser != nil {
- let model: CTTabStripModel = controller.browser.tabStripModel
- let count = model.count()
- if count > 0 {
- for i in 0...(count - 1) {
- let document: KMMainDocument = model.tabContents(at: Int32(i)) as? KMMainDocument ?? KMMainDocument()
- if document.isHome {
- continue
- }
-
- if !(FileManager.default.fileExists(atPath: document.fileURL?.path ?? "")) {
- continue
- }
-
- if document.fileURL != nil {
- files.append(document.fileURL!)
- }
- }
- }
- }
- }
- }
- return files
- }
- }
|