mgrLM // Simplify userDataFolderExists().

This commit is contained in:
ShikiSuen 2022-05-21 14:55:10 +08:00
parent b781400f45
commit b84fe50964
2 changed files with 4 additions and 5 deletions

View File

@ -302,7 +302,7 @@ extension ctlInputMethod {
} }
@objc func openUserDataFolder(_: Any?) { @objc func openUserDataFolder(_: Any?) {
if !mgrLangModel.checkIfUserDataFolderExists() { if !mgrLangModel.userDataFolderExists {
return return
} }
NSWorkspace.shared.openFile( NSWorkspace.shared.openFile(

View File

@ -271,7 +271,7 @@ enum mgrLangModel {
} }
static func chkUserLMFilesExist(_ mode: InputMode) -> Bool { static func chkUserLMFilesExist(_ mode: InputMode) -> Bool {
if !checkIfUserDataFolderExists() { if !userDataFolderExists {
return false return false
} }
if !ensureFileExists(userPhrasesDataPath(mode)) if !ensureFileExists(userPhrasesDataPath(mode))
@ -309,9 +309,8 @@ enum mgrLangModel {
return true return true
} }
// //
// static var userDataFolderExists: Bool {
static func checkIfUserDataFolderExists() -> Bool {
let folderPath = mgrLangModel.dataFolderPath(isDefaultFolder: false) let folderPath = mgrLangModel.dataFolderPath(isDefaultFolder: false)
var isFolder = ObjCBool(false) var isFolder = ObjCBool(false)
var folderExist = FileManager.default.fileExists(atPath: folderPath, isDirectory: &isFolder) var folderExist = FileManager.default.fileExists(atPath: folderPath, isDirectory: &isFolder)