From 35cd391ecd62b6c0c4e9d28ebde0af0d9f68e5e0 Mon Sep 17 00:00:00 2001 From: matkuki Date: Mon, 21 Oct 2019 21:18:01 +0200 Subject: Fix for Windows drive changes This adds a drive change command to every Windows `execAction` call that starts with the `cd` command. Tested with the `libmodbus` C library (https://github.com/stephane/libmodbus). --- nimterop/build.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nimterop/build.nim b/nimterop/build.nim index f96593e..c1eb7ee 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -29,7 +29,14 @@ proc execAction*(cmd: string, retry = 0, nostderr = false): string = ccmd = "" ret = 0 when defined(Windows): - ccmd = "cmd /c " & cmd + var filteredCmd = cmd + if cmd.startsWith("cd"): + var + colonIndex = cmd.find(":") + driveLetter = cmd.substr(colonIndex-1, colonIndex) + if driveLetter[0].isAlphaAscii() and driveLetter[1] == ':': + filteredCmd = &"{driveLetter} && {cmd}" + ccmd = "cmd /c " & filteredCmd elif defined(posix): ccmd = cmd else: -- cgit v1.2.3