]> git.r.bdr.sh - rbdr/mobius/blame - hotline/transfer.go
Merge pull request #10 from jhalter/implement_file_timestamps
[rbdr/mobius] / hotline / transfer.go
CommitLineData
6988a057
JH
1package hotline
2
3import (
4 "bytes"
5 "encoding/binary"
6 "errors"
7)
8
df2735b2 9type transfer struct {
6988a057
JH
10 Protocol [4]byte // "HTXF" 0x48545846
11 ReferenceNumber [4]byte // Unique ID generated for the transfer
12 DataSize [4]byte // File size
13 RSVD [4]byte // Not implemented in Hotline Protocol
14}
15
df2735b2 16var HTXF = [4]byte{0x48, 0x54, 0x58, 0x46} // (HTXF) is the only supported transfer protocol
6988a057 17
df2735b2
JH
18func (tf *transfer) Write(b []byte) (int, error) {
19 if err := binary.Read(bytes.NewReader(b), binary.BigEndian, tf); err != nil {
20 return 0, err
6988a057
JH
21 }
22
df2735b2
JH
23 if tf.Protocol != HTXF {
24 return 0, errors.New("invalid protocol")
6988a057
JH
25 }
26
df2735b2 27 return len(b), nil
6988a057 28}