From 002618fd5cac12bfc6521169a4400d2f81b9be31 Mon Sep 17 00:00:00 2001
From: Tristan Walter <twalter@orn.mpg.de>
Date: Wed, 28 Oct 2020 20:12:36 +0100
Subject: [PATCH] fix for windows

---
 Application/src/grabber/main.cpp   | 6 +++++-
 Application/src/grabber/pvinfo.cpp | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Application/src/grabber/main.cpp b/Application/src/grabber/main.cpp
index d15b35d..4912995 100644
--- a/Application/src/grabber/main.cpp
+++ b/Application/src/grabber/main.cpp
@@ -372,7 +372,11 @@ int main(int argc, char** argv)
             _wd = _wd / "usr" / "share" / "trex";
             //Debug("change directory to conda environment resource folder: '%S'", &_wd.str());
             
-            if(chdir(_wd.c_str()))
+#if defined(WIN32)
+            if (!SetCurrentDirectoryA(_wd.c_str()))
+#else
+            if (chdir(_wd.c_str()))
+#endif
                 Except("Cannot change directory to '%S'", &_wd.str());
         }
 #endif
diff --git a/Application/src/grabber/pvinfo.cpp b/Application/src/grabber/pvinfo.cpp
index 1d5161a..a40fd68 100644
--- a/Application/src/grabber/pvinfo.cpp
+++ b/Application/src/grabber/pvinfo.cpp
@@ -218,7 +218,11 @@ int main(int argc, char**argv) {
         _wd = _wd / "usr" / "share" / "trex";
         //Debug("change directory to conda environment resource folder: '%S'", &_wd.str());
         
-        if(chdir(_wd.c_str()))
+#if defined(WIN32)
+        if (!SetCurrentDirectoryA(_wd.c_str()))
+#else
+        if (chdir(_wd.c_str()))
+#endif
             Except("Cannot change directory to '%S'", &_wd.str());
     }
 #endif
-- 
GitLab