MCPcopy Create free account
hub / github.com/pydio/cells / Write

Method Write

common/crypto/materials.go:277–308  ·  view source on GitHub ↗
(writer io.Writer)

Source from the content-addressed store, hash-verified

275}
276
277func (h *EncryptedBlockHeader) Write(writer io.Writer) (int, error) {
278 totalWritten := 0
279
280 n, err := writer.Write(h.Nonce)
281 if err != nil {
282 return 0, nil
283 }
284 totalWritten += n
285
286 hasOptions := h.Options != nil
287 lenBytes := make([]byte, 4)
288
289 if hasOptions {
290 h.dataLength = h.dataLength | headerOptionsFlag
291 }
292 binary.BigEndian.PutUint32(lenBytes, h.dataLength)
293 n, err = writer.Write(lenBytes)
294 if err != nil {
295 return 0, nil
296 }
297 totalWritten += n
298
299 if hasOptions {
300 n, err = h.Options.Write(writer)
301 if err != nil {
302 return 0, err
303 }
304 totalWritten += n
305 }
306
307 return totalWritten, nil
308}
309
310func (h *EncryptedBlockHeader) Read(reader io.Reader) (int, error) {
311 totalRead := 0

Callers 1

CalculateOutputSizeMethod · 0.95

Calls 2

makeFunction · 0.85
WriteMethod · 0.45

Tested by

no test coverage detected