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:
parent
24ff493d04
commit
3f0a6c8f9d
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user