1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/shell: improve 'ncget' command

Allow to specify destination directory and concat the filename
automatically.
This commit is contained in:
Benjamin Valentin 2022-08-01 17:06:43 +02:00
parent 24ff493d04
commit 3f0a6c8f9d

View File

@ -121,7 +121,16 @@ static int _nanocoap_get_handler(int argc, char **argv)
}
dst = buffer;
} else {
char *filename = strrchr(url, '/');
dst = argv[2];
if (_is_dir(dst) && filename) {
if (snprintf(buffer, sizeof(buffer), "%s%s",
dst, filename + 1) >= (int)sizeof(buffer)) {
printf("Output file path too long\n");
return -ENOBUFS;
}
dst = buffer;
}
}
/* alternatively write the file to stdout */