Added support for windows network shares (\\box\share format paths)

This commit is contained in:
Dave Aitken 2011-07-07 02:38:01 -07:00
parent 04aa45fcd8
commit 0b0c76626b

View File

@ -1880,7 +1880,7 @@ let s:Path = {}
function! s:Path.AbsolutePathFor(str)
let prependCWD = 0
if s:running_windows
let prependCWD = a:str !~# '^.:\(\\\|\/\)'
let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)'
else
let prependCWD = a:str !~# '^/'
endif
@ -2109,7 +2109,12 @@ endfunction
"If running windows, cache the drive letter for this path
function! s:Path.extractDriveLetter(fullpath)
if s:running_windows
let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '')
if a:fullpath =~ '^\(\\\\\|\/\/\)'
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', '')
endif
else
let self.drive = ''
endif
@ -2489,6 +2494,9 @@ function! s:Path.WinToUnixPath(pathstr)
"remove the x:\ of the front
let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "")
"remove the \\ network share from the front
let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "")
"convert all \ chars to /
let toReturn = substitute(toReturn, '\', '/', "g")
@ -4114,4 +4122,4 @@ endfunction
"reset &cpo back to users setting
let &cpo = s:old_cpo
" vim: set sw=4 sts=4 et fdm=marker:
" vim: set sw=4 sts=4 et fdm=marker: