diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 674ca03..223b61f 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -174,11 +174,25 @@ function! s:Path.copy(dest) call s:Path.createParentDirectories(a:dest) - let dest = s:Path.WinToUnixPath(a:dest) + if !nerdtree#runningWindows() + let dest = s:Path.WinToUnixPath(a:dest) + else + let dest = a:dest + endif - let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars()) + if !exists('g:NERDTreeCopyCmd') + if self.isDirectory + let cmd_prefix = g:NERDTreeCopyDirCmd + else + let cmd_prefix = g:NERDTreeCopyFileCmd + endif + else + let cmd_prefix = g:NERDTreeCopyCmd + end + + let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars()) let success = system(cmd) - if success != 0 + if v:shell_error != 0 throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'" endif endfunction @@ -187,7 +201,11 @@ endfunction " "returns 1 if copying is supported for this OS function! s:Path.CopyingSupported() - return exists('g:NERDTreeCopyCmd') + if !exists('g:NERDTreeCopyCmd') + return exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd') + endif + + return 1 endfunction "FUNCTION: Path.copyingWillOverwrite(dest) {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 0bcfe96..15cc2d9 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -103,6 +103,8 @@ call s:initVariable("g:NERDTreeWinSize", 31) "Note: the space after the command is important if nerdtree#runningWindows() call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') + call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ') + call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ') else call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ')