Commits

ZyX_I  committed 803ea94

Fixed os.path.exists and os.path.abspath under windows

  • Participants
  • Parent commits a33b80b
  • Tags release-0.1.16

Comments (0)

Files changed (1)

File plugin/frawor/os.vim

 let s:os.path={}
 "▶3 os.path.abspath   :: path + FS → path
 function s:os.path.abspath(path)
-    let components=s:os.path.split(expand(fnameescape(a:path), 1))
+    let components=s:os.path.split(fnamemodify(a:path, ':p'))
+    if empty(components[-1])
+        call remove(components, -1)
+    endif
     if components[0] is# '.'
         let components[:0]=[fnamemodify('.', ':p')]
         if len(components[0])>1
                 \s:os.path.normpath(s:os.path.realpath(a:path2)))
 endfunction
 "▶3 os.path.exists    :: path + FS → Bool
-function s:os.path.exists(path)
-    return !empty(glob(fnameescape(a:path), 1))
-endfunction
+if s:os.name is# 'nt'
+    function s:os.path.exists(path)
+        " Path cannot contain these symbols, but glob('\*') will list files
+        " Same for «"<>|», but those are not special to glob()
+        if a:path=~#'[*?]'
+            return 0
+        endif
+        return !empty(glob(fnameescape(a:path), 1))
+    endfunction
+else
+    function s:os.path.exists(path)
+        return !empty(glob(fnameescape(a:path), 1))
+    endfunction
+endif
 "▶3 os.path.isdir     :: path + FS → Bool
 function s:os.path.isdir(path)
     return isdirectory(s:os.path.abspath(a:path))