From 45829daa856b376b1ab04d415917110b71b1dec5 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Wed, 5 Feb 2025 22:27:17 +0100 Subject: Apply formatting --- Hotline/Shared/URLAdditions.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Hotline/Shared/URLAdditions.swift') diff --git a/Hotline/Shared/URLAdditions.swift b/Hotline/Shared/URLAdditions.swift index 1f25541..5e6a450 100644 --- a/Hotline/Shared/URLAdditions.swift +++ b/Hotline/Shared/URLAdditions.swift @@ -5,14 +5,15 @@ extension URL { 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)" + 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) { @@ -20,7 +21,7 @@ extension URL { filePath = self.appending(component: finalName).path(percentEncoded: false) counter += 1 } - + return filePath } } -- cgit