mirror of
https://github.com/preservim/nerdtree.git
synced 2025-02-12 21:25:16 +08:00
Merge pull request #78 from actionshrimp/master
Add windows network share support
This commit is contained in:
commit
217d9f6651
|
@ -2076,7 +2076,7 @@ let s:Path = {}
|
||||||
function! s:Path.AbsolutePathFor(str)
|
function! s:Path.AbsolutePathFor(str)
|
||||||
let prependCWD = 0
|
let prependCWD = 0
|
||||||
if s:running_windows
|
if s:running_windows
|
||||||
let prependCWD = a:str !~# '^.:\(\\\|\/\)'
|
let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)'
|
||||||
else
|
else
|
||||||
let prependCWD = a:str !~# '^/'
|
let prependCWD = a:str !~# '^/'
|
||||||
endif
|
endif
|
||||||
|
@ -2305,7 +2305,13 @@ endfunction
|
||||||
"If running windows, cache the drive letter for this path
|
"If running windows, cache the drive letter for this path
|
||||||
function! s:Path.extractDriveLetter(fullpath)
|
function! s:Path.extractDriveLetter(fullpath)
|
||||||
if s:running_windows
|
if s:running_windows
|
||||||
|
if a:fullpath =~ '^\(\\\\\|\/\/\)'
|
||||||
|
"For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share
|
||||||
|
let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '')
|
||||||
|
let self.drive = substitute(self.drive, '/', '\', "g")
|
||||||
|
else
|
||||||
let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '')
|
let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '')
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
let self.drive = ''
|
let self.drive = ''
|
||||||
endif
|
endif
|
||||||
|
@ -2508,7 +2514,7 @@ function! s:Path.readInfoFromDisk(fullpath)
|
||||||
let lastPathComponent = self.getLastPathComponent(0)
|
let lastPathComponent = self.getLastPathComponent(0)
|
||||||
|
|
||||||
"get the path to the new node with the parent dir fully resolved
|
"get the path to the new node with the parent dir fully resolved
|
||||||
let hardPath = resolve(self.strTrunk()) . '/' . lastPathComponent
|
let hardPath = resolve(self.strTrunk()) . lastPathComponent
|
||||||
|
|
||||||
"if the last part of the path is a symlink then flag it as such
|
"if the last part of the path is a symlink then flag it as such
|
||||||
let self.isSymLink = (resolve(hardPath) != hardPath)
|
let self.isSymLink = (resolve(hardPath) != hardPath)
|
||||||
|
@ -2686,9 +2692,13 @@ function! s:Path._str()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.strTrunk() {{{3
|
"FUNCTION: Path.strTrunk() {{{3
|
||||||
"Gets the path without the last segment on the end.
|
"Gets the path without the last segment on the end, always with an endslash
|
||||||
function! s:Path.strTrunk()
|
function! s:Path.strTrunk()
|
||||||
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
|
let toReturn = self.drive . '/' . join(self.pathSegments[0:-2], '/')
|
||||||
|
if toReturn !~# '\/$'
|
||||||
|
let toReturn .= '/'
|
||||||
|
endif
|
||||||
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: Path.tabnr() {{{3
|
" FUNCTION: Path.tabnr() {{{3
|
||||||
|
@ -2723,6 +2733,9 @@ function! s:Path.WinToUnixPath(pathstr)
|
||||||
"remove the x:\ of the front
|
"remove the x:\ of the front
|
||||||
let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "")
|
let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "")
|
||||||
|
|
||||||
|
"remove the \\ network share from the front
|
||||||
|
let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "")
|
||||||
|
|
||||||
"convert all \ chars to /
|
"convert all \ chars to /
|
||||||
let toReturn = substitute(toReturn, '\', '/', "g")
|
let toReturn = substitute(toReturn, '\', '/', "g")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user