5 // Created by Pawel Dabrowski on 30/05/2018.
6 // Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved.
14 var appDelegate:AppDelegate {
15 return UIApplication.shared.delegate as! AppDelegate
18 func ebookExists(bookSlug: String) -> Bool {
19 let path = FileType.ebook.pathForFileName(filename: bookSlug, bookSlug: bookSlug)
21 return FileManager.default.fileExists(atPath: path)
24 static func audiobookExists(audioBookUrlString: String, bookSlug: String) -> Bool {
25 let fileName = (audioBookUrlString as NSString).lastPathComponent
26 return FileManager.default.fileExists(atPath: FileType.audiobook.pathForFileName(filename: fileName, bookSlug: bookSlug))
29 static func audiobookPathIfExists(audioBookUrlString: String, bookSlug: String) -> URL? {
30 let fileName = (audioBookUrlString as NSString).lastPathComponent
31 let path = FileType.audiobook.pathForFileName(filename: fileName, bookSlug: bookSlug)
33 if FileManager.default.fileExists(atPath: path) {
34 return URL(fileURLWithPath: path)