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