Skip to content

Instantly share code, notes, and snippets.

@nanoant

nanoant/icget.swift

Forked from anongit/icget.swift
Created Aug 13, 2019
Embed
What would you like to do?
Download .icloud files
// See: https://apple.stackexchange.com/questions/328329/is-there-a-way-via-the-command-line-to-cause-icloud-files-to-download
import Foundation
func main() {
let fm = FileManager.default
for path in CommandLine.arguments[1...] {
let url = NSURL.fileURL(withPath: path)
guard fm.fileExists(atPath: url.path) else {
fputs("\(url.path): doesn't exist\n", stderr)
continue
}
do {
try fm.startDownloadingUbiquitousItem(at: url)
} catch {
fputs("\(url.path): \(error.localizedDescription)\n", stderr)
}
}
}
main()
import Foundation
func main() {
let fm = FileManager.default
for path in CommandLine.arguments[1...] {
let url = NSURL.fileURL(withPath: path)
guard fm.fileExists(atPath: url.path) else {
fputs("\(url.path): doesn't exist\n", stderr)
continue
}
do {
try fm.evictUbiquitousItem(at: url)
} catch {
fputs("\(url.path): \(error.localizedDescription)\n", stderr)
}
}
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.