Merge pull request #145 from matkuki/patch-1
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).
This commit is contained in:
commit
3c960c140c
1 changed files with 10 additions and 1 deletions
|
|
@ -29,7 +29,16 @@ proc execAction*(cmd: string, retry = 0, nostderr = false): string =
|
||||||
ccmd = ""
|
ccmd = ""
|
||||||
ret = 0
|
ret = 0
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
ccmd = "cmd /c " & cmd
|
var filteredCmd = cmd
|
||||||
|
if cmd.toLower().startsWith("cd"):
|
||||||
|
var
|
||||||
|
colonIndex = cmd.find(":")
|
||||||
|
driveLetter = cmd.substr(colonIndex-1, colonIndex)
|
||||||
|
if (driveLetter[0].isAlphaAscii() and
|
||||||
|
driveLetter[1] == ':' and
|
||||||
|
colonIndex == 4):
|
||||||
|
filteredCmd = &"{driveLetter} && {cmd}"
|
||||||
|
ccmd = "cmd /c " & filteredCmd
|
||||||
elif defined(posix):
|
elif defined(posix):
|
||||||
ccmd = cmd
|
ccmd = cmd
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue