-
Notifications
You must be signed in to change notification settings - Fork 89
fix bug Handle folder name format based on OS #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@abdularis bro look look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in the file transfer sender by normalizing folder path separators based on the receiver's operating system. The change ensures that folder paths use backslashes for Windows receivers and forward slashes for Linux/macOS receivers.
- Adds OS-specific folder path separator normalization before sending file headers
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if (mReceiverDev.getOSName() == "Windows") { | ||
| mFolderName.replace("/", "\\"); | ||
| } else { | ||
| // Linux & macOS | ||
| mFolderName.replace("\\", "/"); |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
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.
| 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; |
No description provided.