Added option to overwrite existing files when saving artwork
This commit is contained in:
committed by
Kim Wittenburg
parent
4548f43797
commit
e287a935b1
@@ -54,6 +54,10 @@ public class Artwork: iTunesType {
|
||||
public func saveToURL(url: NSURL, filename: String) throws {
|
||||
let directory = url.filePathURL!.path!
|
||||
let filePath = directory.stringByAppendingString("/\(filename).tiff")
|
||||
|
||||
if !Preferences.sharedPreferences.overwriteExistingFiles && NSFileManager.defaultManager().fileExistsAtPath(filePath) {
|
||||
return
|
||||
}
|
||||
|
||||
try NSFileManager.defaultManager().createDirectoryAtPath(directory, withIntermediateDirectories: true, attributes: nil)
|
||||
let _ = NSFileManager.defaultManager().createFileAtPath(filePath, contents: saveImage?.TIFFRepresentation, attributes: nil)
|
||||
|
||||
Reference in New Issue
Block a user