From dbab84bb2b37da40c27b6ade36920d2b96612ba5 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Wed, 31 Aug 2011 23:22:55 +0200 Subject: xolox#misc#path#is_relative() --- path.vim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'path.vim') diff --git a/path.vim b/path.vim index 2b4510f..ee0f2e2 100644 --- a/path.vim +++ b/path.vim @@ -1,6 +1,6 @@ " Vim auto-load script " Author: Peter Odding -" Last Change: March 15, 2011 +" Last Change: August 31, 2011 " URL: http://peterodding.com/code/vim/misc/ let s:windows_compatible = has('win32') || has('win64') @@ -69,6 +69,7 @@ endfunction " Join a directory and filename into a single pathname. function! xolox#misc#path#merge(parent, child, ...) + " TODO Use isabs()! if type(a:parent) == type('') && type(a:child) == type('') if s:windows_compatible let parent = substitute(a:parent, '[\\/]\+$', '', '') @@ -127,6 +128,18 @@ else endfunction endif +" Check whether a path is relative. + +function! xolox#misc#path#is_relative(path) + if a:path =~ '^\w\+://' + return 0 + elseif s:windows_compatible + return a:path !~ '^\(\w:\|[\\/]\)' + else + return a:path !~ '^/' + endif +endfunction + " Create a temporary directory and return the path. function! xolox#misc#path#tempdir() -- cgit v1.2.3