diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2020-05-19 18:03:14 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2020-05-19 18:03:14 +0200 |
commit | 5126dbbeaf47e11d3799b3ce89bede9b97c6b7d6 (patch) | |
tree | b8db47314da31a61dcb81a4a64d213e68b8e768c | |
parent | 5fdbde2d279a235767c38cc74619441138f09153 (diff) | |
download | vis-open_rej-5126dbbeaf47e11d3799b3ce89bede9b97c6b7d6.tar.gz |
Another version of file_exists function.
-rw-r--r-- | init.lua | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -1,14 +1,11 @@ -function file_exists(name) - local f=io.open(name,"r") - if f~=nil then - io.close(f) - return true - else - return false - end +local function file_exists(path) + local f = io.open(path) + if f == nil then return false + else f:close() return true + end end -function open_rej_file(file) +local function open_rej_file(file) local rejfile = file .. '.rej' if file_exists(rejfile) then vis:command('open ' .. rejfile) @@ -18,3 +15,4 @@ end vis.events.subscribe(vis.events.FILE_OPEN, function (file) open_rej_file(file.path) end) + |