readGzFile reads the given file from disk completely and returns the content.
(sf string, encryption bool, encKeyPath string)
| 81 | |
| 82 | // readGzFile reads the given file from disk completely and returns the content. |
| 83 | func readGzFile(sf string, encryption bool, encKeyPath string) ([]byte, error) { |
| 84 | fd, err := os.Open(sf) |
| 85 | if err != nil { |
| 86 | return nil, errors.Wrapf(err, "error opening file [%v]", sf) |
| 87 | } |
| 88 | defer func() { |
| 89 | if err := fd.Close(); err != nil { |
| 90 | log.Printf("[WARNING] error closing file [%v]: %v", sf, err) |
| 91 | } |
| 92 | }() |
| 93 | |
| 94 | data, err := readGzData(fd, encryption, encKeyPath) |
| 95 | if err != nil { |
| 96 | return nil, errors.Wrapf(err, "error reading data from file [%v]", sf) |
| 97 | } |
| 98 | return data, nil |
| 99 | } |
| 100 | |
| 101 | func readGzData(r io.Reader, encryption bool, encKeyPath string) ([]byte, error) { |
| 102 | if encryption { |
no test coverage detected