On Fri, 27 Nov 2015 15:35:23 +0100
Bernhard Nortmann <[email protected]> wrote:

> The two new commands both imply that a (simple) progress bar
> display is requested. "multi[write]" allows to upload a group
> of files with a single command, resulting in their transfer
> showing a common, 'overall' progress status.
> 
> Signed-off-by: Bernhard Nortmann <[email protected]>
> ---
>  fel.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/fel.c b/fel.c
> index c9081b6..13565f3 100644
> --- a/fel.c
> +++ b/fel.c
> @@ -1271,6 +1271,9 @@ int main(int argc, char **argv)
>                       "       exe[cute] address               Call function 
> address\n"
>                       "       read address length file        Write memory 
> contents into file\n"
>                       "       write address file              Store file 
> contents into memory\n"
> +                     "       write-with-progress addr file   \"write\" with 
> progress bar\n"
> +                     "       multi[write] # addr file ...    
> \"write-with-progress\" multiple files,\n"
> +                     "                                       sharing a 
> common progress status\n"
>                       "       ver[sion]                       Show BROM 
> version\n"
>                       "       clear address length            Clear memory\n"
>                       "       fill address length value       Fill memory\n"
> @@ -1338,6 +1341,34 @@ int main(int argc, char **argv)
>                               file_upload(handle, argv[3], strtoul(argv[2], 
> NULL, 0));
>                       }
>                       skip=3;
> +             } else if (strcmp(argv[1], "write-with-progress") == 0 && argc 
> > 3) {
> +                     size_t size = file_size(argv[3]);
> +                     if (size > 0) {
> +                             progress_start(progress_bar, size);
> +                             file_upload(handle, argv[3], strtoul(argv[2], 
> NULL, 0));
> +                     }
> +                     skip=3;
> +             } else if ((strcmp(argv[1], "multiwrite") == 0 ||
> +                         strcmp(argv[1], "multi") == 0) && argc > 4) {
> +                     size_t count = strtoul(argv[2], NULL, 0); /* file count 
> */
> +                     skip = 2;
> +                     if (count > 0) {
> +                             unsigned int i;
> +
> +                             /* get all file sizes, keeping track of total 
> bytes */
> +                             size_t total_bytes = 0;
> +                             for (i = 0; i < count; i++)
> +                                     total_bytes += file_size(argv[4 + i*2]);

What if 'count' is much larger than 'argc' here?

> +
> +                             progress_start(progress_bar, total_bytes);
> +
> +                             /* now transfer each file in turn */
> +                             for (i = 0; i < count; i++)
> +                                     file_upload(handle, argv[4 + i*2],
> +                                                 strtoul(argv[3 + i*2], 
> NULL, 0));
> +
> +                             skip += count * 2;
> +                     }
>               } else if (strcmp(argv[1], "read") == 0 && argc > 4) {
>                       size_t size = strtoul(argv[3], NULL, 0);
>                       void *buf = malloc(size);



-- 
Best regards,
Siarhei Siamashka

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to