Conditions | 7 |
Total Lines | 30 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | package main |
||
13 | func JoinFile(files []string, out string) error { |
||
14 | //sort with file name or we will join files with wrong order |
||
15 | sort.Strings(files) |
||
16 | var bar *pb.ProgressBar |
||
17 | |||
18 | if DisplayProgressBar() { |
||
19 | Printf("Start joining \n") |
||
20 | bar = pb.StartNew(len(files)).Prefix(color.CyanString("Joining")) |
||
21 | } |
||
22 | |||
23 | outf, err := os.OpenFile(out, os.O_CREATE|os.O_WRONLY, 0600) |
||
24 | if err != nil { |
||
25 | return err |
||
26 | } |
||
27 | defer outf.Close() |
||
28 | |||
29 | for _, f := range files { |
||
30 | if err = copy(f, outf); err != nil { |
||
31 | return err |
||
32 | } |
||
33 | if DisplayProgressBar() { |
||
34 | bar.Increment() |
||
35 | } |
||
36 | } |
||
37 | |||
38 | if DisplayProgressBar() { |
||
39 | bar.Finish() |
||
40 | } |
||
41 | |||
42 | return nil |
||
43 | } |
||
55 |