From 7226074954bcdf2675cf527ae0b6b791564457e5 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 30 Sep 2010 17:56:59 +0800 Subject: [PATCH] Added 'gcp file dest_file' syntax management --- gcp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gcp b/gcp index 11e2a98..99ea640 100755 --- a/gcp +++ b/gcp @@ -305,7 +305,7 @@ class GCP(): source_fd = open(source_file, 'rb') filename = os.path.basename(source_file) assert(filename) - dest_file = self.__filename_fix(os.path.join(dest_path,filename),options) + dest_file = self.__filename_fix(options.dest_file,options) if options.dest_file else self.__filename_fix(os.path.join(dest_path,filename),options) if os.path.exists(dest_file) and not options.force: warning (_("File [%s] already exists, skipping it !") % dest_file.decode('utf-8','replace')) self.journal.copyFailed() @@ -523,7 +523,8 @@ class GCP(): @return: a tuple (boolean, message) where the boolean is the success of the arguments validation, and message is the error message to print when necessary""" _usage=""" - %prog [options] FILE1 [FILE2 ...] DEST + %prog [options] FILE DEST + %prog [options] FILE1 [FILE2 ...] DEST-DIR %prog --help for options list """ @@ -599,6 +600,16 @@ class GCP(): options.preserve = preserve self.__sourcesSaving(options, args) + + if len(args) == 2: + dest_path = os.path.abspath(os.path.expanduser(args[1])) + if not os.path.exists(dest_path) or os.path.isfile(dest_path): + options.dest_file = dest_path + args[1] = os.path.dirname(dest_path) + else: + options.dest_file = None + else: + options.dest_file = None #if there is an other instance of gcp, we send options to it if not self._main_instance: