Added support for the copy command for both file and directory nodes on Windows systems
This commit is contained in:
parent
40993e9010
commit
b5519197e9
@ -174,11 +174,25 @@ function! s:Path.copy(dest)
|
|||||||
|
|
||||||
call s:Path.createParentDirectories(a:dest)
|
call s:Path.createParentDirectories(a:dest)
|
||||||
|
|
||||||
|
if !nerdtree#runningWindows()
|
||||||
let dest = s:Path.WinToUnixPath(a:dest)
|
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)
|
let success = system(cmd)
|
||||||
if success != 0
|
if v:shell_error != 0
|
||||||
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
|
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -187,7 +201,11 @@ endfunction
|
|||||||
"
|
"
|
||||||
"returns 1 if copying is supported for this OS
|
"returns 1 if copying is supported for this OS
|
||||||
function! s:Path.CopyingSupported()
|
function! s:Path.CopyingSupported()
|
||||||
return exists('g:NERDTreeCopyCmd')
|
if !exists('g:NERDTreeCopyCmd')
|
||||||
|
return exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd')
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.copyingWillOverwrite(dest) {{{1
|
"FUNCTION: Path.copyingWillOverwrite(dest) {{{1
|
||||||
|
@ -103,6 +103,8 @@ call s:initVariable("g:NERDTreeWinSize", 31)
|
|||||||
"Note: the space after the command is important
|
"Note: the space after the command is important
|
||||||
if nerdtree#runningWindows()
|
if nerdtree#runningWindows()
|
||||||
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ')
|
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
|
else
|
||||||
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ')
|
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ')
|
||||||
call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ')
|
call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user