nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit b5519197e9b27a3a99f6310148084c84f8ef3d4a
parent 40993e90101332e88b68c15d1ea4fd3ea84ab2a4
Author: Skyler Lipthay <skyler.lipthay@gmail.com>
Date:   Wed, 23 Jan 2013 00:23:56 -0800

Added support for the copy command for both file and directory nodes on Windows systems

Diffstat:
Mlib/nerdtree/path.vim | 26++++++++++++++++++++++----
Mplugin/NERD_tree.vim | 2++
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git 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
@@ -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 ')