Skip to content
Snippets Groups Projects
Commit fe850695 authored by Philippe Gorley's avatar Philippe Gorley Committed by Philippe Gorley
Browse files

file transfer: rename duplicate files

Add duplicate number after filename, but before extension, and start
count at 1 instead of 0.

Before, it would be '(0)file.jpg', now it is 'file (1).jpg'.

Change-Id: I8bb35cfce63447cf024e5b5dfb18a0410b507ef6
parent 58601ca1
No related branches found
No related tags found
No related merge requests found
......@@ -252,8 +252,12 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
auto wantedFilename = filename + info.displayName;
auto duplicate = 0;
while (std::ifstream(wantedFilename).good()) {
wantedFilename = filename + "(" + std::to_string(duplicate) + ")" + info.displayName;
++duplicate;
auto extensionIdx = info.displayName.find_last_of(".");
if (extensionIdx == std::string::npos)
wantedFilename = filename + info.displayName + " (" + std::to_string(duplicate) + ")";
else
wantedFilename = filename + info.displayName.substr(0, extensionIdx) + " (" + std::to_string(duplicate) + ")" + info.displayName.substr(extensionIdx);
}
model->acceptTransfer(priv->conversation_->uid, interactionId, wantedFilename);
} catch (...) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment