From ea499a0f02cb91a8c7b8c77dfefd47d917b9a349 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyfox@inbox.ru>
Date: Wed, 28 Jan 2009 23:08:31 +0200
Subject: [PATCH] copy/move dialog: add trailing '/' to default destination path (fix #181)
Problem:
When user tried to copy/move file (F5/F6) - he could run into trouble if
destination directory is removed (it can be removed by user from another mc session).
Operation is performed and(!) file is renamed.
So when when user issues 'cp /tmp/a.file /tmp/b' - he gets not expected /tmp/b/a.file,
but /tmp.b !
Solution:
Add trailing space for destination directory for non-local copy/move(F5/F6) operations.
So operation, given above will take form: 'cp /tmp/a.file /tmp/b/' disambiguating b
meaning.
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
---
src/file.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/src/file.c b/src/file.c
index 73346ca..80b0ed7 100644
a
|
b
|
|
50 | 50 | #include <sys/stat.h> |
51 | 51 | #include <unistd.h> |
52 | 52 | |
| 53 | #include <mhl/string.h> |
| 54 | |
53 | 55 | #include "global.h" |
54 | 56 | #include "tty.h" |
55 | 57 | #include "eregex.h" |
… |
… |
panel_operate (void *source_panel, FileOperation operation, |
1783 | 1785 | } |
1784 | 1786 | } else if (operation != OP_DELETE) { |
1785 | 1787 | char *dest_dir; |
| 1788 | char *dest_dir_; |
1786 | 1789 | |
1787 | 1790 | /* Forced single operations default to the original name */ |
1788 | 1791 | if (force_single) |
… |
… |
panel_operate (void *source_panel, FileOperation operation, |
1792 | 1795 | else |
1793 | 1796 | dest_dir = panel->cwd; |
1794 | 1797 | |
| 1798 | /* |
| 1799 | * Add trailing backslash only when do non-locally ops. |
| 1800 | * It saves user from occasional file renames (when destination |
| 1801 | * dir is deleted) |
| 1802 | */ |
| 1803 | if (force_single) |
| 1804 | // just copy |
| 1805 | dest_dir_ = mhl_str_dup (dest_dir); |
| 1806 | else |
| 1807 | { |
| 1808 | // add trailing separator |
| 1809 | dest_dir_ = mhl_str_concat (dest_dir, PATH_SEP_STR); |
| 1810 | if (!dest_dir_) { |
| 1811 | file_op_context_destroy (ctx); |
| 1812 | return 0; |
| 1813 | } |
| 1814 | } |
| 1815 | |
1795 | 1816 | dest = |
1796 | | file_mask_dialog (ctx, operation, cmd_buf, dest_dir, |
| 1817 | file_mask_dialog (ctx, operation, cmd_buf, dest_dir_, |
1797 | 1818 | single_entry, &do_bg); |
| 1819 | mhl_mem_free(dest_dir_); |
| 1820 | |
1798 | 1821 | if (!dest) { |
1799 | 1822 | file_op_context_destroy (ctx); |
1800 | 1823 | return 0; |