+// String returns a string representation of a file transfer and its progress for display in the GetInfo window
+// Example:
+// MasterOfOrionII1.4.0. 0% 197.9M
+func (ft *FileTransfer) String() string {
+ trunc := fmt.Sprintf("%.21s", ft.FileName)
+ return fmt.Sprintf("%-21s %.3s%% %6s\n", trunc, ft.percentComplete(), ft.formattedTransferSize())
+}
+
+func (ft *FileTransfer) percentComplete() string {
+ ft.bytesSentCounter.mux.Lock()
+ defer ft.bytesSentCounter.mux.Unlock()
+ return fmt.Sprintf(
+ "%v",
+ math.RoundToEven(float64(ft.bytesSentCounter.Total)/float64(binary.BigEndian.Uint32(ft.TransferSize))*100),
+ )
+}