Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Add custom ePub unzip path option #181

Merged
merged 1 commit into from
Dec 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Source/EPUBCore/FREpubParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ class FREpubParser: NSObject, SSZipArchiveDelegate {
Unzip, delete and read an epub file.
Returns a FRBook.
*/
func readEpub(epubPath withEpubPath: String, removeEpub: Bool = true) -> FRBook? {
func readEpub(epubPath withEpubPath: String, removeEpub: Bool = true, unzipPath: String? = nil) -> FRBook? {
epubPathToRemove = withEpubPath
shouldRemoveEpub = removeEpub

var isDir: ObjCBool = false
let fileManager = FileManager.default
let bookName = (withEpubPath as NSString).lastPathComponent
bookBasePath = (kApplicationDocumentsDirectory as NSString).appendingPathComponent(bookName)


if let bookUnzipPath = FolioReader.shared.unzipPath, fileManager.fileExists(atPath: bookUnzipPath) {
bookBasePath = bookUnzipPath
} else {
bookBasePath = kApplicationDocumentsDirectory
}

bookBasePath = (bookBasePath as NSString).appendingPathComponent(bookName)

guard fileManager.fileExists(atPath: withEpubPath) else {
print("Epub file does not exist.")
return nil
Expand Down
1 change: 1 addition & 0 deletions Source/FolioReaderKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ enum MediaOverlayStyle: Int {
*/
open class FolioReader: NSObject {
open static let shared = FolioReader()
open var unzipPath: String?
static let defaults = UserDefaults.standard
open weak var delegate: FolioReaderDelegate?
open weak var readerCenter: FolioReaderCenter?
Expand Down