Archived
1

Added option to overwrite existing files when saving artwork

This commit is contained in:
Kim Wittenburg
2015-09-15 14:29:57 +02:00
committed by Kim Wittenburg
parent 4548f43797
commit e287a935b1
3 changed files with 66 additions and 37 deletions

View File

@@ -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)