+ dir = typeof dir === 'string' ? dir : this.getCurrentDirectory();
+ if (dir.charAt(dir.length - 1) !== '/') {
+ dir += '/';
+ }
+ var target = OC.basename(targetPath);
+ if (!_.isArray(fileNames)) {
+ fileNames = [fileNames];
+ }
+ var copyFileFunction = function(fileName) {
+ var $tr = self.findFileEl(fileName);
+ self.showFileBusyState($tr, true);
+ if (targetPath.charAt(targetPath.length - 1) !== '/') {
+ // make sure we move the files into the target dir,
+ // not overwrite it
+ targetPath = targetPath + '/';
+ }
+ var targetPathAndName = targetPath + fileName;
+ if ((dir + fileName) === targetPathAndName) {
+ var dotIndex = targetPathAndName.indexOf(".");
+ if ( dotIndex > 1) {
+ var leftPartOfName = targetPathAndName.substr(0, dotIndex);
+ var fileNumber = leftPartOfName.match(/\d+/);
+ // TRANSLATORS name that is appended to copied files with the same name, will be put in parenthesis and appened with a number if it is the second+ copy