summaryrefslogtreecommitdiff
path: root/src/console/dlt-convert.c
diff options
context:
space:
mode:
authorKHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>2020-08-06 15:37:27 +0700
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2021-01-06 09:27:28 +0900
commit807528d2b4d319953866359e1ee7d60691ea4b33 (patch)
tree481bde473536bfca7981bf534fb5c06bb28d24ed /src/console/dlt-convert.c
parent22ff642d242f580322286fd82d12d688333847ce (diff)
downloadDLT-daemon-807528d2b4d319953866359e1ee7d60691ea4b33.tar.gz
dlt-convert: replace system() by dlt_execute_command()
Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
Diffstat (limited to 'src/console/dlt-convert.c')
-rw-r--r--src/console/dlt-convert.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/console/dlt-convert.c b/src/console/dlt-convert.c
index 595f7f9..fa42466 100644
--- a/src/console/dlt-convert.c
+++ b/src/console/dlt-convert.c
@@ -216,7 +216,6 @@ int main(int argc, char *argv[])
char text[DLT_CONVERT_TEXTBUFSIZE] = { 0 };
/* For handling compressed files */
- char command[COMMAND_SIZE] = { 0 };
char tmp_filename[FILENAME_SIZE] = { 0 };
struct stat st = { 0 };
struct dirent **files = { 0 };
@@ -359,22 +358,22 @@ int main(int argc, char *argv[])
}
for (index = optind; index < argc; index++) {
- memset(command, 0, COMMAND_SIZE);
-
/* Check extension of input file
* If it is a compressed file, uncompress it
*/
- if (strcmp(get_filename_ext(argv[index]), DLT_EXTENSION) != 0)
- snprintf(command, COMMAND_SIZE, "tar xf %s -C %s",
- argv[index], DLT_CONVERT_WS);
- else
- snprintf(command, COMMAND_SIZE, "cp %s %s",
- argv[index], DLT_CONVERT_WS);
+ if (strcmp(get_filename_ext(argv[index]), DLT_EXTENSION) != 0) {
+ syserr = dlt_execute_command(NULL, "tar", "xf", argv[index], "-C", DLT_CONVERT_WS, NULL);
+ if (syserr != 0)
+ fprintf(stderr, "ERROR: Failed to uncompress %s to %s with error [%d]\n",
+ argv[index], DLT_CONVERT_WS, WIFEXITED(syserr));
+ }
+ else {
+ syserr = dlt_execute_command(NULL, "cp", argv[index], DLT_CONVERT_WS, NULL);
+ if (syserr != 0)
+ fprintf(stderr, "ERROR: Failed to copy %s to %s with error [%d]\n",
+ argv[index], DLT_CONVERT_WS, WIFEXITED(syserr));
+ }
- syserr = system(command);
- if (syserr != 0)
- fprintf(stderr, "ERROR: Failed to execute command [%s] with error [%d]\n",
- command, syserr);
}
n = scandir(DLT_CONVERT_WS, &files, NULL, alphasort);