Skip to content

Instantly share code, notes, and snippets.

@kewlbear
Created May 18, 2017 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kewlbear/6d6fd967a9de9f5d4eb78bb08dd00052 to your computer and use it in GitHub Desktop.
Save kewlbear/6d6fd967a9de9f5d4eb78bb08dd00052 to your computer and use it in GitHub Desktop.
if let normalized = url.withUnsafeFileSystemRepresentation({ fileSystemRepresentation -> URL? in
guard let bytes = fileSystemRepresentation, let path = String(utf8String: bytes) else {
print("not UTF8?", fileSystemRepresentation)
return nil
}
return URL(fileURLWithPath: path.decomposedStringWithCanonicalMapping)
}),
normalized != url {
do {
try FileManager.default.moveItem(at: url, to: normalized)
print("normalized", url.lastPathComponent)
}
catch {
// TODO: ?
print(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment