10 type transfer struct {
11 Protocol [4]byte // "HTXF" 0x48545846
12 ReferenceNumber [4]byte // Unique ID generated for the transfer
13 DataSize [4]byte // File size
14 RSVD [4]byte // Not implemented in Hotline Protocol
17 var HTXF = [4]byte{0x48, 0x54, 0x58, 0x46} // (HTXF) is the only supported transfer protocol
19 func (tf *transfer) Write(b []byte) (int, error) {
20 if err := binary.Read(bytes.NewReader(b), binary.BigEndian, tf); err != nil {
24 if tf.Protocol != HTXF {
25 return 0, errors.New("invalid protocol")
31 func receiveFile(r io.Reader, targetFile, resForkFile, infoFork, counterWriter io.Writer) error {
32 var ffo flattenedFileObject
33 if _, err := ffo.ReadFrom(r); err != nil {
37 // Write the information fork
38 _, err := io.Copy(infoFork, &ffo.FlatFileInformationFork)
43 if _, err = io.CopyN(targetFile, io.TeeReader(r, counterWriter), ffo.dataSize()); err != nil {
47 if ffo.FlatFileHeader.ForkCount == [2]byte{0, 3} {
48 if err := binary.Read(r, binary.BigEndian, &ffo.FlatFileResForkHeader); err != nil {
52 if _, err = io.CopyN(resForkFile, io.TeeReader(r, counterWriter), ffo.rsrcSize()); err != nil {