Added more necessary parts to compression.

This commit is contained in:
Caleb Gardner
2021-02-24 05:58:18 -06:00
parent 8a91e1a1c1
commit a123935250
5 changed files with 66 additions and 6 deletions
+17
View File
@@ -0,0 +1,17 @@
package squashfs
import "reflect"
func (w *Writer) compressData(data []byte) ([]byte, error) {
if reflect.DeepEqual(data, make([]byte, len(data))) {
return nil, nil
}
compressedData, err := w.compressor.Compress(data)
if err != nil {
return nil, err
}
if len(data) <= len(compressedData) {
return data, nil
}
return compressedData, nil
}