Add app directory check

Fixes #77
This commit is contained in:
Max Goedjen
2020-09-20 18:54:43 -07:00
parent 2177fec7d5
commit de2252fccb
3 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import Foundation
struct ApplicationDirectoryController {
}
extension ApplicationDirectoryController {
var isInApplicationsDirectory: Bool {
#if DEBUG
return true
#else
let bundlePath = Bundle.main.bundlePath
for directory in NSSearchPathForDirectoriesInDomains(.applicationDirectory, .allDomainsMask, true) {
if bundlePath.hasPrefix(directory) {
return true
}
}
return false
#endif
}
}