aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Library/URLAdditions.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hotline/Library/URLAdditions.swift')
-rw-r--r--Hotline/Library/URLAdditions.swift55
1 files changed, 0 insertions, 55 deletions
diff --git a/Hotline/Library/URLAdditions.swift b/Hotline/Library/URLAdditions.swift
deleted file mode 100644
index 0ba2100..0000000
--- a/Hotline/Library/URLAdditions.swift
+++ /dev/null
@@ -1,55 +0,0 @@
-import Foundation
-import UniformTypeIdentifiers
-
-extension URL {
- func generateUniqueFilePath(filename base: String) -> String {
- let fileManager = FileManager.default
- var finalName = base
- var counter = 2
-
- // Helper function to generate a new filename with a counter
- func makeFileName() -> String {
- let baseName = (base as NSString).deletingPathExtension
- let extensionName = (base as NSString).pathExtension
- return extensionName.isEmpty ? "\(baseName) \(counter)" : "\(baseName) \(counter).\(extensionName)"
- }
-
- // Check if file exists and append counter until a unique name is found
- var filePath = self.appending(component: finalName).path(percentEncoded: false)
- while fileManager.fileExists(atPath: filePath) {
- finalName = makeFileName()
- filePath = self.appending(component: finalName).path(percentEncoded: false)
- counter += 1
- }
-
- return filePath
- }
-}
-
-extension UTType {
- var canBePreviewedByQuickLook: Bool {
- // QuickLook supports most common document types
- let supportedSupertypes: [UTType] = [
- .image,
- .movie,
- .audio,
- .pdf,
- .font,
- .usdz,
- .text,
- .sourceCode,
- .spreadsheet,
- .presentation,
-
-// Microsoft Office
- .init(filenameExtension: "doc")!,
- .init(filenameExtension: "docx")!,
- .init(filenameExtension: "xls")!,
- .init(filenameExtension: "xlsx")!,
- .init(filenameExtension: "ppt")!,
- .init(filenameExtension: "pptx")!,
- ]
-
- return supportedSupertypes.contains { self.conforms(to: $0) }
- }
-}