File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 10
10
}
11
11
12
12
// Display a progress bar: xxx% [=======> ]
13
- $ percent = (int )floor ( $ downloaded * 100 / $ download_size );
14
- $ percentage = sprintf ('%3d%% ' , $ percent );
15
- $ arrow_length = 40 ;
16
- $ arrow_tail_length = max (1 , floor (($ percent / 100 * $ arrow_length ) - 3 ));
17
- $ space_length = max (0 , $ arrow_length - $ arrow_tail_length - 3 );
18
- $ arrow = '[ ' . str_repeat ('= ' , $ arrow_tail_length ) . '> ' . str_repeat (' ' , $ space_length ) . '] ' ;
19
- echo ' ' . $ percentage . ' ' . $ arrow . "\r" ;
13
+ $ progress_size = 40 ;
14
+ $ fraction_downloaded = $ downloaded / $ download_size ;
15
+ $ dots = round ($ fraction_downloaded * $ progress_size );
16
+ printf ('%3.0f%% [ ' , $ fraction_downloaded * 100 );
17
+ $ i = 0 ;
18
+ for ( ; $ i < $ dots - 1 ; $ i ++) {
19
+ echo '= ' ;
20
+ }
21
+ echo '> ' ;
22
+ for ( ; $ i < $ progress_size - 1 ; $ i ++) {
23
+ echo ' ' ;
24
+ }
25
+ echo '] ' . "\r" ;
20
26
});
21
27
$ curl ->complete (function ($ instance ) {
22
28
echo "\n" . 'download complete ' . "\n" ;
You can’t perform that action at this time.
0 commit comments