func (b block) GetDataForConfigFile() (attrsForCf []byte, dataForCf []byte) { if b.blockType == blockType_simply { dataForCf = b.data } else { dataForCf = []byte{} addresses := []addresInTOC{} for _, sb := range b.subBlocks { headerAndAttrs := []byte{} subBlockAttrs := sb.Attrs.getData() utils.AddToSlice(&headerAndAttrs, getHeaderForCf(len(subBlockAttrs), len(subBlockAttrs)), subBlockAttrs) headerAndData := []byte{} utils.AddToSlice(&headerAndData, getHeaderForCf(len(sb.Data), len(sb.Data)), sb.Data) pos := utils.AddToSlice(&dataForCf, headerAndAttrs, headerAndData) addresses = append(addresses, addresInTOC{AttrsPos: int32(pos[0]), DataPos: int32(pos[1])}) } addTableOfContent(&dataForCf, addresses) } if len(dataForCf) > 0 { var err error var newData []byte if newData, err = zlibwrapper.Compress(dataForCf); err != nil { panic("Ошибка сжатия данных блока: " + b.attrs.name) } prepareDataForConfigFile(&newData) dataForCf = newData } attrsForCf = b.attrs.getData() return }
func getTestData_BlockCF() []byte { data, _ := zlibwrapper.Compress([]byte(getTestData_SimpleBlockData())) return data }