From eaed2443fa77e133809d9c47937ccd301f969fed Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 12 Oct 2010 03:33:26 +0200 Subject: core.actions: improved fm.paste() --- ranger/core/actions.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'ranger/core/actions.py') diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 2f6d2719..50c322c4 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -748,8 +748,15 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): cwd = self.env.get_directory(original_path) cwd.load_content() - original_path = self.env.cwd.path + cwd = self.env.cwd + original_path = cwd.path one_file = copied_files[0] + if overwrite: + cp_flags = ['--backup=numbered', '-af', '--'] + mv_flags = ['--backup=numbered', '-f', '--'] + else: + cp_flags = ['--backup=numbered', '-a', '--'] + mv_flags = ['--backup=numbered', '--'] if self.env.cut: self.env.copy.clear() @@ -758,17 +765,24 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): descr = "moving: " + one_file.path else: descr = "moving files from: " + one_file.dirname - obj = CommandLoader(args=['mv', '--backup=existing', - '--suffix=_', '-ft', self.env.cwd.path] + \ - [f.path for f in copied_files], descr=descr) + obj = CommandLoader(args=['mv'] + mv_flags + + + [f.path for f in copied_files] + + [cwd.path], descr=descr) else: if len(copied_files) == 1: descr = "copying: " + one_file.path else: descr = "copying files from: " + one_file.dirname - obj = CommandLoader(args=['cp', '--backup=existing', '--archive', - '--suffix=_', '-frt', self.env.cwd.path] + \ - [f.path for f in self.env.copy], descr=descr) + if not overwrite and len(copied_files) == 1 \ + and one_file.dirname == cwd.path: + # Special case: yypp + # copying a file onto itself -> create a backup + obj = CommandLoader(args=['cp', '-f'] + cp_flags + + [one_file.path, one_file.path], descr=descr) + else: + obj = CommandLoader(args=['cp'] + cp_flags + + [f.path for f in copied_files] + + [cwd.path], descr=descr) obj.signal_bind('after', refresh) self.loader.add(obj) -- cgit 1.4.1-2-gfad0