aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2020-05-19 18:03:14 +0200
committerMatěj Cepl <mcepl@cepl.eu>2020-05-19 18:03:14 +0200
commit5126dbbeaf47e11d3799b3ce89bede9b97c6b7d6 (patch)
treeb8db47314da31a61dcb81a4a64d213e68b8e768c
parent5fdbde2d279a235767c38cc74619441138f09153 (diff)
downloadvis-open_rej-5126dbbeaf47e11d3799b3ce89bede9b97c6b7d6.tar.gz
Another version of file_exists function.
-rw-r--r--init.lua16
1 files changed, 7 insertions, 9 deletions
diff --git a/init.lua b/init.lua
index d94b8e9..8aaff39 100644
--- a/init.lua
+++ b/init.lua
@@ -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)
+