Skip to content

Instantly share code, notes, and snippets.

@abjurato
Created October 4, 2020 12:05
Show Gist options
  • Save abjurato/57bc8a48751b190dbb70a767e96d9f4d to your computer and use it in GitHub Desktop.
Save abjurato/57bc8a48751b190dbb70a767e96d9f4d to your computer and use it in GitHub Desktop.
Exclude file from backup and set data protection key
extension FileManager {
public func secureFilesystemItems(_ url: inout URL) throws {
try (url as NSURL).setResourceValue(URLFileProtection.completeUntilFirstUserAuthentication, forKey: .fileProtectionKey)
try (url as NSURL).setResourceValue(NSNumber(true), forKey: URLResourceKey.isExcludedFromBackupKey)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment