Created
May 18, 2017 06:05
-
-
Save kewlbear/6d6fd967a9de9f5d4eb78bb08dd00052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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