summaryrefslogtreecommitdiff
path: root/install.bat
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2019-04-01 16:27:08 -0300
committerHisham Muhammad <hisham@gobolinux.org>2019-04-01 16:29:17 -0300
commit7e9b7e08a8a31501189a32c60fb9cb7bc6b31b5e (patch)
treea92f51e7ae906d74cfefee136afad997a9ce6319 /install.bat
parent8283b817efd6fadad62794045d6bebad71e063cd (diff)
downloadluarocks-7e9b7e08a8a31501189a32c60fb9cb7bc6b31b5e.tar.gz
luarocks-7e9b7e08a8a31501189a32c60fb9cb7bc6b31b5e.tar.bz2
luarocks-7e9b7e08a8a31501189a32c60fb9cb7bc6b31b5e.zip
fs: versions of exists, is_file, is_dir for Unix and Windows that do not fork
Implements versions of exists, is_file, is_dir for POSIX and Windows using io.open only, based on the semantics of their error codes on these platforms. Drops the dependency on TEST.EXE on Windows.
Diffstat (limited to 'install.bat')
-rw-r--r--install.bat13
1 files changed, 11 insertions, 2 deletions
diff --git a/install.bat b/install.bat
index a98b32fd..43b18e1d 100644
--- a/install.bat
+++ b/install.bat
@@ -67,8 +67,17 @@ local function exec(cmd)
67end 67end
68 68
69local function exists(filename) 69local function exists(filename)
70 local cmd = [[.\win32\tools\test -e "]]..filename..[["]] 70 local fd, _, code = io.open(filename, "r")
71 return exec(cmd) 71 if code == 13 then
72 -- code 13 means "Permission denied" on both Unix and Windows
73 -- io.open on folders always fails with code 13 on Windows
74 return true
75 end
76 if fd then
77 fd:close()
78 return true
79 end
80 return false
72end 81end
73 82
74local function mkdir (dir) 83local function mkdir (dir)