// // H5Manager.swift // CommonFrame // // Created by Virgil on 2018/5/22. // Copyright © 2018年 Virgil. All rights reserved. // import UIKit let h5_path = "webhtml" class H5Manager: NSObject { ///检查h5文件是否可用 是否复制到沙盒底下 class func checkIsUse() -> Bool { //获取应用程序的路径 let searchPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) let documentFolderPath = searchPaths[0] let dbFilePath = documentFolderPath + "/\(h5_path)/manifest.json" let fm = FileManager.default let isExist = fm.fileExists(atPath: dbFilePath) /** * 如果不存在 拷贝工程里的数据库到 documents下 ZIP文件压缩时不能带外层文件夹 */ if isExist { try! fm.removeItem(atPath: documentFolderPath + "/\(h5_path)") print("===delele==\(documentFolderPath + "/\(h5_path)")====success") } else { } try! fm.createDirectory(atPath: documentFolderPath + "/\(h5_path)", withIntermediateDirectories: true, attributes: nil) let backupDbPath = Bundle.main.path(forResource: h5_path, ofType: "zip") SSZipArchive.unzipFile(atPath: backupDbPath!, toDestination: documentFolderPath + "/\(h5_path)") print("==H5 0k==") return true } }