MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / startTransfer

Method startTransfer

app/src/IO/FileTransmission/ZMODEM.cpp:76–110  ·  view source on GitHub ↗

* @brief Starts a ZMODEM file transfer. */

Source from the content-addressed store, hash-verified

74 * @brief Starts a ZMODEM file transfer.
75 */
76void IO::Protocols::ZMODEM::startTransfer(const QString& filePath)
77{
78 Q_ASSERT(!filePath.isEmpty());
79 Q_ASSERT(m_maxRetries > 0);
80
81 if (isActive())
82 cancelTransfer();
83
84 m_file.setFileName(filePath);
85 if (!m_file.open(QIODevice::ReadOnly)) {
86 Q_EMIT finished(false, tr("Cannot open file: %1").arg(m_file.errorString()));
87 return;
88 }
89
90 m_filePath = filePath;
91 m_fileSize = m_file.size();
92 m_bytesSent = 0;
93 m_fileOffset = 0;
94 m_retryCount = 0;
95 m_parseState = ParseState::Idle;
96 m_headerBuf.clear();
97 m_zdleEscape = false;
98
99 static constexpr qint64 kZmodemMaxFileSize = static_cast<qint64>(0xFFFFFFFFULL);
100 if (m_fileSize > kZmodemMaxFileSize) [[unlikely]] {
101 m_file.close();
102 Q_EMIT finished(false,
103 tr("File is too large for ZMODEM (%1 bytes, limit 4 GiB).").arg(m_fileSize));
104 return;
105 }
106
107 Q_EMIT progressChanged(0, m_fileSize);
108
109 sendZRQINIT();
110}
111
112/**
113 * @brief Cancels the current transfer.

Callers 1

beginTransmissionMethod · 0.45

Calls 7

isEmptyMethod · 0.80
errorStringMethod · 0.80
setFileNameMethod · 0.45
openMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected