Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/transfer/sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ void Sender::sendData()
void Sender::sendHeader()
{
QString fName = QDir(mFile->fileName()).dirName();

if (mReceiverDev.getOSName() == "Windows") {
mFolderName.replace("/", "\\");
} else {
// Linux & macOS
mFolderName.replace("\\", "/");
Comment on lines +160 to +165
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic assumes only three operating systems (Windows, Linux, macOS). Consider using a more robust approach that explicitly handles all expected OS values or adds a default case. Additionally, using Qt's QDir::toNativeSeparators() and QDir::fromNativeSeparators() would be more maintainable than manual string replacement.

Suggested change
if (mReceiverDev.getOSName() == "Windows") {
mFolderName.replace("/", "\\");
} else {
// Linux & macOS
mFolderName.replace("\\", "/");
// Normalize folder name to use forward slashes first.
QString normalizedFolder = QDir::fromNativeSeparators(mFolderName);
const QString osName = mReceiverDev.getOSName();
if (osName.compare("Windows", Qt::CaseInsensitive) == 0) {
// Receiver is Windows: use backslashes.
mFolderName = normalizedFolder;
mFolderName.replace("/", "\\");
} else if (osName.compare("Linux", Qt::CaseInsensitive) == 0
|| osName.compare("macOS", Qt::CaseInsensitive) == 0) {
// Receiver is Linux or macOS: keep normalized forward slashes.
mFolderName = normalizedFolder;
} else {
// Fallback for other/unknown OS names: use normalized forward slashes.
mFolderName = normalizedFolder;

Copilot uses AI. Check for mistakes.
}

QJsonObject obj( QJsonObject::fromVariantMap({
{"name", fName},
Expand Down