Commits

ZyX_I  committed 3869d9f

@/os: Improved os.path.exists and os.path.isfile functions: they now don't assume that existing file must be readable

  • Participants
  • Parent commits 6aae2d2

Comments (0)

Files changed (2)

File doc/frawor.txt

 os.path.samefile :: path, path + FS -> Bool          *frawor-os-path-samefile*
         Returns 1 if both pathnames refer to the same actual file.
 os.path.exists :: path + FS -> Bool                    *frawor-os-path-exists*
-        Returns 1 if file or directory with given name exists (for file: and 
-        is readable), 0 otherwise.
+        Returns 1 if file or directory with given name exists, 0 otherwise.
 os.path.isdir :: path + FS -> Bool                      *frawor-os-path-isdir*
         Returns 1 if given path is existing directory, 0 otherwise.
+os.path.isfile :: path + FS -> Bool                    *frawor-os-path-isfile*
+        Returns 1 if given path is existing file, 0 otherwise.
                                                          *frawor-os-path-walk*
 os.path.walk :: path, (arg, path, [ component ] -> _)[, arg] + FS -> _
         Directory tree walk with callback function:

File plugin/frawor/os.vim

     finish
 endif
 execute frawor#Setup('0.0', {'@/resources': '0.0'}, 1)
-"▶1 Define messages
-if v:lang=~?'ru'
-    let s:_messages={
-                \
-            \}
-else
-    let s:_messages={
-                \
-            \}
-endif
 "▶1 os resource
 let s:os={}
 "▶2 os.fullname
 endfunction
 "▶3 os.path.exists    :: path + FS → Bool
 function s:os.path.exists(path)
-    return s:os.path.isdir(a:path) || filereadable(a:path)
+    return !empty(glob(escape(a:path, '[`*\?]')))
 endfunction
 "▶3 os.path.isdir     :: path + FS → Bool
 let s:os.path.isdir=function('isdirectory')
+"▶3 os.path.isfile    :: path + FS → Bool
+function s:os.path.isfile(path)
+    return s:os.path.exists(a:path) && !s:os.path.isdir(a:path)
+endfunction
 "▶3 os.path.walk      :: path, F[, arg] + FS
 function s:os.path.walk(path, Func, ...)
     let arg=get(a:000, 0, 0)