mgrLM // Simplify userDataFolderExists().
This commit is contained in:
parent
b781400f45
commit
b84fe50964
|
@ -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(
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue