aboutsummaryrefslogtreecommitdiff
path: root/hotline/file_resume_data.go
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-11-28 00:39:17 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2025-11-28 00:39:17 +0100
commit9f67542d8469db45c823e347b1868b3582d9e5a7 (patch)
tree88741b3d8633758e4f6f5cbc292f338bc99602a0 /hotline/file_resume_data.go
parent8f9edf2f3bb18f7ab1a04ead182a1daf2cfd41d9 (diff)
parent8ddb9bb228389b198a76d6df21de005da4fad66b (diff)
Merge branch 'master' of https://github.com/jhalter/mobiusHEADmain
Diffstat (limited to 'hotline/file_resume_data.go')
-rw-r--r--hotline/file_resume_data.go62
1 files changed, 29 insertions, 33 deletions
diff --git a/hotline/file_resume_data.go b/hotline/file_resume_data.go
index 5dfd2d8..1926bc6 100644
--- a/hotline/file_resume_data.go
+++ b/hotline/file_resume_data.go
@@ -3,38 +3,59 @@ package hotline
import (
"bytes"
"encoding/binary"
+ "fmt"
)
// FileResumeData is sent when a client or server would like to resume a transfer from an offset
type FileResumeData struct {
Format [4]byte // "RFLT"
Version [2]byte // Always 1
- RSVD [34]byte // Unused
+ RSVD [34]byte // Present in the Hotline protocol docs, but unused. Left here for documentation purposes.
ForkCount [2]byte // Length of ForkInfoList. Either 2 or 3 depending on whether file has a resource fork
ForkInfoList []ForkInfoList
+}
+
+// ForkType represents a 4-byte fork type identifier
+type ForkType [4]byte
- //readOffset int // TODO
+// String returns a string representation of the fork type
+func (ft ForkType) String() string {
+ return fmt.Sprintf("%c%c%c%c", ft[0], ft[1], ft[2], ft[3])
}
type ForkInfoList struct {
- Fork [4]byte // "DATA" or "MACR"
- DataSize [4]byte // offset from which to resume the transfer of data
- RSVDA [4]byte // Unused
- RSVDB [4]byte // Unused
+ Fork ForkType // "DATA", "INFO", or "MACR"
+ DataSize [4]byte // offset from which to resume the transfer of data
+ RSVDA [4]byte // Present in the Hotline protocol docs, but unused. Left here for documentation purposes.
+ RSVDB [4]byte // Present in the Hotline protocol docs, but unused. Left here for documentation purposes.
}
+var (
+ ForkTypeDATA = ForkType{0x44, 0x41, 0x54, 0x41} // DATA: Data fork
+ ForkTypeINFO = ForkType{0x49, 0x4E, 0x46, 0x4F} // INFO: Information fork
+ ForkTypeMACR = ForkType{0x4d, 0x41, 0x43, 0x52} // MACR: Mac resource fork
+)
+
func NewForkInfoList(b []byte) *ForkInfoList {
return &ForkInfoList{
- Fork: [4]byte{0x44, 0x41, 0x54, 0x41},
+ Fork: ForkTypeDATA,
DataSize: [4]byte{b[0], b[1], b[2], b[3]},
RSVDA: [4]byte{},
RSVDB: [4]byte{},
}
}
+var (
+ FormatFILP = [4]byte{0x46, 0x49, 0x4c, 0x50} // Flattened file format: "FILP"
+ FormatRFLT = [4]byte{0x52, 0x46, 0x4C, 0x54} // File resume format: "RFLT" (?)
+
+ PlatformAMAC = [4]byte{0x41, 0x4D, 0x41, 0x43} // Mac platform: "AMAC"
+ PlatformMWIN = [4]byte{0x4D, 0x57, 0x49, 0x4E} // Windows platform: "MWIN"
+)
+
func NewFileResumeData(list []ForkInfoList) *FileResumeData {
return &FileResumeData{
- Format: [4]byte{0x52, 0x46, 0x4C, 0x54}, // RFLT
+ Format: FormatRFLT,
Version: [2]byte{0, 1},
RSVD: [34]byte{},
ForkCount: [2]byte{0, uint8(len(list))},
@@ -42,31 +63,6 @@ func NewFileResumeData(list []ForkInfoList) *FileResumeData {
}
}
-//
-//func (frd *FileResumeData) Read(p []byte) (int, error) {
-// buf := slices.Concat(
-// frd.Format[:],
-// frd.Version[:],
-// frd.RSVD[:],
-// frd.ForkCount[:],
-// )
-// for _, fil := range frd.ForkInfoList {
-// buf = append(buf, fil...)
-// _ = binary.Write(&buf, binary.LittleEndian, fil)
-// }
-//
-// var buf bytes.Buffer
-// _ = binary.Write(&buf, binary.LittleEndian, frd.Format)
-// _ = binary.Write(&buf, binary.LittleEndian, frd.Version)
-// _ = binary.Write(&buf, binary.LittleEndian, frd.RSVD)
-// _ = binary.Write(&buf, binary.LittleEndian, frd.ForkCount)
-// for _, fil := range frd.ForkInfoList {
-// _ = binary.Write(&buf, binary.LittleEndian, fil)
-// }
-//
-// return buf.Bytes(), nil
-//}
-
func (frd *FileResumeData) BinaryMarshal() ([]byte, error) {
var buf bytes.Buffer
_ = binary.Write(&buf, binary.LittleEndian, frd.Format)