From 364da4e3cf681275ee3f2ce5c30d98c5b7af6462 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 2 Jul 2024 21:44:19 -0700 Subject: [PATCH] Add AppConfig.dataFolder. --- Core/Sources/Core/AppConfig.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Core/Sources/Core/AppConfig.swift b/Core/Sources/Core/AppConfig.swift index 9ded15208..fd4c482cc 100644 --- a/Core/Sources/Core/AppConfig.swift +++ b/Core/Sources/Core/AppConfig.swift @@ -32,6 +32,20 @@ public final class AppConfig { public static func cacheSubfolder(named name: String) -> URL { subfolder(name, in: cacheFolder) } + + public static let dataFolder: URL = { + +#if os(macOS) + var dataFolder = try FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: false) + dataFolder = dataFolder.appendingPathComponent(appName) + + try FileManager.default.createDirectory(at: dataFolder, withIntermediateDirectories: true, attributes: nil) + return dataFolder + +#elseif os(iOS) + FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! +#endif + }() } private extension AppConfig {