17 type FileTransfer struct {
20 ReferenceNumber []byte
22 TransferSize []byte // total size of all items in the folder. Only used in FolderUpload action
23 FolderItemCount []byte
26 fileResumeData *FileResumeData
29 func (ft *FileTransfer) String() string {
31 out := fmt.Sprintf("%s\t %v", ft.FileName, percentComplete)
36 func (ft *FileTransfer) ItemCount() int {
37 return int(binary.BigEndian.Uint16(ft.FolderItemCount))
42 // 00 02 // PathItemCount
46 // 73 75 62 66 6f 6c 64 65 72 // "subfolder"
50 // 73 75 62 66 6f 6c 64 65 72 2d 74 65 73 74 66 69 6c 65 2d 35 6b // "subfolder-testfile-5k"
51 func readFolderUpload(buf []byte) folderUpload {
52 dataLen := binary.BigEndian.Uint16(buf[0:2])
55 DataSize: [2]byte{buf[0], buf[1]}, // Size of this structure (not including data size element itself)
56 IsFolder: [2]byte{buf[2], buf[3]},
57 PathItemCount: [2]byte{buf[4], buf[5]},
58 FileNamePath: buf[6 : dataLen+2],
65 func (fu *folderUpload) UnmarshalBinary(b []byte) error {
66 fu.DataSize = [2]byte{b[0], b[1]}
67 fu.IsFolder = [2]byte{b[2], b[3]}
68 fu.PathItemCount = [2]byte{b[4], b[5]}
73 type folderUpload struct {
80 func (fu *folderUpload) FormattedPath() string {
81 pathItemLen := binary.BigEndian.Uint16(fu.PathItemCount[:])
83 var pathSegments []string
84 pathData := fu.FileNamePath
86 for i := uint16(0); i < pathItemLen; i++ {
88 pathSegments = append(pathSegments, string(pathData[3:3+segLen]))
89 pathData = pathData[3+segLen:]
92 return strings.Join(pathSegments, pathSeparator)