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