From 65d523bd0417d5cf9b9b20167ee5754eb7b5e791 Mon Sep 17 00:00:00 2001 From: BanceDev Date: Wed, 4 Sep 2024 16:39:14 -0400 Subject: added api functions for isFile, isDirectory, isReadable, and isWriteable --- .lush/scripts/example.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to '.lush/scripts') diff --git a/.lush/scripts/example.lua b/.lush/scripts/example.lua index 04cb516..9cf3c96 100644 --- a/.lush/scripts/example.lua +++ b/.lush/scripts/example.lua @@ -49,3 +49,20 @@ lush.cd(cwd) if lush.exists("~/.lush/scripts/example.lua") then print("example.lua exists") end + +-- isFile and isDir check if a path points to a file or a directory +if lush.isFile("~/.lush/scripts/example.lua") then + print("example.lua is a file") +end + +if not lush.isDirectory("~/.lush/scripts/example.lua") then + print("example.lua is not a directory") +end + +-- you can also check if a file is readable/writeable +if lush.isReadable("~/.lush/scripts/example.lua") then + print("example.lua is readable") +end +if lush.isWriteable("~/.lush/scripts/example.lua") then + print("example.lua is writeable") +end -- cgit v1.2.3-59-g8ed1b