-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileManager+FileProviderDomainLogDirectory.swift
More file actions
38 lines (33 loc) · 1.55 KB
/
FileManager+FileProviderDomainLogDirectory.swift
File metadata and controls
38 lines (33 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
// SPDX-License-Identifier: LGPL-3.0-or-later
@preconcurrency import FileProvider
import Foundation
public extension FileManager {
///
/// Return log directory specific to the file provider domain distinguished by the given identifier.
///
/// If such directory does not exist yet, this attempts to create it implicitly.
///
/// - Parameters:
/// - identifier: File provider domain identifier which is used to isolate log data for different file provider domains of the same extension.
///
/// - Returns: A directory based on what the system returns for looking up standard directories. Likely in the sandbox containers of the file provider extension. Very unlikely to fail by returning `nil`.
///
func fileProviderDomainLogDirectory(for identifier: NSFileProviderDomainIdentifier) -> URL? {
guard let applicationGroupContainer = applicationGroupContainer() else {
return nil
}
let logsDirectory = applicationGroupContainer
.appendingPathComponent("File Provider Domains", isDirectory: true)
.appendingPathComponent(identifier.rawValue, isDirectory: true)
.appendingPathComponent("Logs", isDirectory: true)
if fileExists(atPath: logsDirectory.path) == false {
do {
try createDirectory(at: logsDirectory, withIntermediateDirectories: true)
} catch {
return nil
}
}
return logsDirectory
}
}