mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2025-12-13 15:32:15 +08:00
fix a config.json reading issue
This commit is contained in:
parent
8e13e947d5
commit
723e982bf3
|
|
@ -50,7 +50,15 @@ struct Patch: ParsableCommand {
|
|||
return URL(fileURLWithPath: $0)
|
||||
}
|
||||
)
|
||||
var config: URL = URL(fileURLWithPath: "config.json")
|
||||
var config: URL = {
|
||||
var size: UInt32 = 0
|
||||
_NSGetExecutablePath(nil, &size)
|
||||
var buffer = [CChar](repeating: 0, count: Int(size))
|
||||
guard _NSGetExecutablePath(&buffer, &size) == 0, let path = String(utf8String: buffer) else {
|
||||
return URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
|
||||
}
|
||||
return URL(fileURLWithPath: path).resolvingSymlinksInPath().deletingLastPathComponent().appendingPathComponent("config.json")
|
||||
}()
|
||||
|
||||
func run() throws {
|
||||
let configs = try JSONDecoder().decode([Config].self, from: Data(contentsOf: self.config))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user