From c8674f1f34f1cb314276e66155b6018742a668f5 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Sat, 29 Apr 2023 13:16:45 -0700 Subject: [PATCH] get path to DLL for settings --- extension/main.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/extension/main.go b/extension/main.go index e308ad7..b8329f7 100644 --- a/extension/main.go +++ b/extension/main.go @@ -15,6 +15,7 @@ import ( "fmt" "log" "os" + "path/filepath" "strconv" "strings" "time" @@ -74,6 +75,19 @@ func getDir() string { func loadConfig() { // load config from file as JSON functionName := "loadConfig" + + // get location of this dll + dllPath, err := filepath.Abs(os.Args[0]) + if err != nil { + writeLog(functionName, fmt.Sprintf(`["Error getting DLL path: %v", "ERROR"]`, err)) + return + } + + // set the addon directory to the parent directory of the dll + ADDON_FOLDER = filepath.Dir(dllPath) + LOG_FILE = ADDON_FOLDER + "\\attendanceTracker.log" + CONFIG_FILE = ADDON_FOLDER + "\\config.json" + file, err := os.Open(CONFIG_FILE) if err != nil { writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err)) @@ -243,9 +257,11 @@ func goRVExtensionArgs(output *C.char, outputsize C.size_t, input *C.char, argv temp := fmt.Sprintf("Function: %s nb params: %d", C.GoString(input), argc) switch C.GoString(input) { - case "logAttendance": // callExtension ["serverEvent", [_hash] call CBA_fnc_encodeJSON]; - if argc == 1 { - go writeAttendance(out[0]) + case "logAttendance": + { // callExtension ["serverEvent", [_hash] call CBA_fnc_encodeJSON]; + if argc == 1 { + go writeAttendance(out[0]) + } } }