From d90bfc966837750165d5c5e2a4cf632854283844 Mon Sep 17 00:00:00 2001 From: Norbert Schulz Date: Thu, 29 Aug 2024 16:27:58 +0200 Subject: [PATCH] Add --cwd option for setting working directory. --- lib/MainNative/src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/MainNative/src/main.cpp b/lib/MainNative/src/main.cpp index 03299b0e..1cb9294b 100644 --- a/lib/MainNative/src/main.cpp +++ b/lib/MainNative/src/main.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -77,6 +78,7 @@ static void systemDelay(unsigned long ms); static const struct option LONG_OPTIONS[] = {{"help", no_argument, nullptr, 0}, {"serialRxCh", required_argument, nullptr, 0}, {"serialTxCh", required_argument, nullptr, 0}, + {"cwd", required_argument, nullptr, 0}, {nullptr, no_argument, nullptr, 0}}; /* Marks the end. */ /** Program argument default value of the robot name. */ @@ -263,6 +265,10 @@ static int handleCommandLineArguments(PrgArguments& prgArguments, int argc, char { prgArguments.serialTxChannel = optarg; } + else if (0 == strcmp(LONG_OPTIONS[optionIndex].name, "cwd")) + { + chdir(optarg); + } else { status = -1; @@ -307,6 +313,7 @@ static int handleCommandLineArguments(PrgArguments& prgArguments, int argc, char printf("\t--serialTxCh \t\tSet serial tx channel (ZumoComSystem)."); /* Serial txchannel */ printf(" Default: %s\n", PRG_ARG_SERIAL_TX_CH_DEFAULT); /* Serial tx channel default value */ printf("\t-v\t\t\tVerbose mode. Default: Disabled\n"); /* Flag */ + printf("\t--cwd \t\tSpecify working directory."); /* Set process working directory */ } return status;