File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,10 @@ function string:startswith(text)
158158 return false
159159end
160160
161+ function string :endswith (text )
162+ return text == " " or self :sub (-# text ) == text
163+ end
164+
161165function string :lstrip ()
162166 if self == nil then return nil end
163167 local s = self :gsub (' ^%s+' , ' ' )
@@ -418,22 +422,20 @@ end
418422function os .path .isdir (pathname )
419423 if pathname == ' /' then
420424 return true
425+ elseif pathname == ' ' then
426+ return false
421427 elseif windows then
422428 if pathname == ' \\ ' then
423429 return true
424430 elseif pathname :match (' ^%a:[/\\ ]$' ) then
425431 return true
426432 end
427433 end
428- local name = pathname .. ' /'
429- local ok , err , code = os.rename (name , name )
430- if not ok then
431- if code == 13 then
432- return true
433- end
434- return false
434+ local name = pathname
435+ if not name :endswith (' /' ) then
436+ name = name .. ' /'
435437 end
436- return true
438+ return os . path . exists ( name )
437439end
438440
439441
@@ -446,6 +448,13 @@ function os.path.exists(name)
446448 if code == 13 then
447449 return true
448450 end
451+ if code == 30 then
452+ local f = io.open (name ," r" )
453+ if f ~= nil then
454+ io.close (f )
455+ return true
456+ end
457+ end
449458 return false
450459 end
451460 return true
You can’t perform that action at this time.
0 commit comments