summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2011-06-04 10:29:11 +0000
committerTaco Hoekwater <taco@elvenkind.com>2011-06-04 10:29:11 +0000
commitf77e093ae46db3afc856a90d82e8c8b8b8b98246 (patch)
treeee5b21cbad97ff445c81abd894e9a4477b04a040 /Master/texmf-dist/tex
parent92059e84b152ae4706252316513d93c84bab7799 (diff)
better version of file.is_writable() from Hans
git-svn-id: svn://tug.org/texlive/trunk@22770 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/context/base/l-file.lua31
1 files changed, 13 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/context/base/l-file.lua b/Master/texmf-dist/tex/context/base/l-file.lua
index 0cc62c730ef..3fea3b0a7c4 100644
--- a/Master/texmf-dist/tex/context/base/l-file.lua
+++ b/Master/texmf-dist/tex/context/base/l-file.lua
@@ -147,30 +147,25 @@ end
--~ print(file.join("//nas-1","/y"))
function file.is_writable(name)
- if os.type == "windows" then
- local a = attributes(name) or attributes(dirname(name,"."))
- return a and sub(a.permissions,2,2) == "w"
- end
- local f
- local isnew = true
if lfs.isdir(name) then
- name = name .. "/mtxtest.txt"
+ name = name .. "/m_t_x_t_e_s_t.tmp"
+ local f = io.open(name,"wb")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
else
- f = io.open(name, "rb");
- if f then
- f:close()
- isnew = false
- end
- end
- f = io.open(name, "wb");
- if f then
- f:close()
- if isnew then os.remove(name) end
- return true
+ f = io.open(name,"ab")
+ if f then
+ f:close()
+ return true
+ end
end
return false
end
+
function file.is_readable(name)
local a = attributes(name)
return a and sub(a.permissions,1,1) == "r"