Skip to content

Instantly share code, notes, and snippets.

@cmittendorf
Created August 21, 2015 08:44
Show Gist options
  • Save cmittendorf/b680d1a03aefa08583d7 to your computer and use it in GitHub Desktop.
Save cmittendorf/b680d1a03aefa08583d7 to your computer and use it in GitHub Desktop.
A script to enable tracking the DocumentIdentifier for a file on OSX.
#!/usr/bin/env swift
import Foundation
let args = Process.arguments
if (args.count != 2) {
print("usage: \(args[0].lastPathComponent) <file>\n")
exit(-1)
}
let flag = UInt32(UF_TRACKED)
let fileName = args[1] as NSString
if 0 != chflags(fileName.UTF8String, flag) {
let error = String.fromCString(strerror(errno))!
print("Error changing flags: \(error)\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment