Skip to content

Commit

Permalink
fix spurious file not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Feb 19, 2019
1 parent 6057644 commit 3cffd00
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions z.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ function string:startswith(text)
return false
end

function string:endswith(text)
return text == "" or self:sub(-#text) == text
end

function string:lstrip()
if self == nil then return nil end
local s = self:gsub('^%s+', '')
Expand Down Expand Up @@ -418,22 +422,20 @@ end
function os.path.isdir(pathname)
if pathname == '/' then
return true
elseif pathname == '' then
return false
elseif windows then
if pathname == '\\' then
return true
elseif pathname:match('^%a:[/\\]$') then
return true
end
end
local name = pathname .. '/'
local ok, err, code = os.rename(name, name)
if not ok then
if code == 13 then
return true
end
return false
local name = pathname
if not name:endswith('/') then
name = name .. '/'
end
return true
return os.path.exists(name)
end


Expand All @@ -446,6 +448,13 @@ function os.path.exists(name)
if code == 13 then
return true
end
if code == 30 then
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
end
end
return false
end
return true
Expand Down

0 comments on commit 3cffd00

Please sign in to comment.