Added auto-optimizing for sending, made delete -> del alias.
This commit is contained in:
parent
fbc0eb46c4
commit
555bfb5813
|
@ -303,7 +303,7 @@ int parse_args(int ac, char **av, args_t *args)
|
|||
args->dirname = s_dir ? s_dir : NULL;
|
||||
args->newname = aav[2];
|
||||
args->newdir = s_todir ? s_todir : NULL;
|
||||
} else if (!strcmp(aav[0], "del")) {
|
||||
} else if (!strcmp(aav[0], "del") || !strcmp(aav[0], "delete")) {
|
||||
sub_init(del, 1)
|
||||
|
||||
/* get filename */
|
||||
|
|
|
@ -213,7 +213,26 @@ int main(int ac, char **av)
|
|||
/* Check according to menu */
|
||||
switch (args.menu) {
|
||||
case mn_send:
|
||||
err = p7_sendfile(handle, args.local, args.dirname, args.filename,
|
||||
/* get file size */
|
||||
fseek(args.local, 0, SEEK_END);
|
||||
size_t filesize = (p7uint_t)ftell(args.local);
|
||||
rewind(args.local);
|
||||
|
||||
/* get capacity */
|
||||
p7uint_t capacity;
|
||||
err = p7_getcapacity(handle, args.storage, &capacity);
|
||||
if (err) break;
|
||||
|
||||
/* optimize if required */
|
||||
if (filesize > (size_t)capacity) {
|
||||
printf("Not enough space on the device. Let's optimize!\n");
|
||||
err = p7_optimize(handle, args.storage);
|
||||
if (err) break;
|
||||
}
|
||||
|
||||
/* send the file */
|
||||
err = p7_sendstream(handle, args.local, filesize,
|
||||
args.dirname, args.filename,
|
||||
args.storage, 1, args.force ? NULL : &sendfile_confirm,
|
||||
args.nicedisp ? &sendfile_display : NULL);
|
||||
break;
|
||||
|
|
Reference in New Issue