diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-08-23 15:04:30 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-08-23 15:04:30 -0700 |
commit | aeaa7d150cacb5f858f1b516ca3e2234c68b8e55 (patch) | |
tree | eb49f5b3b3607457c9b27175111434fe6b1e490b | |
parent | 019a8292793077106b9b6927b9ca727918fad9ec (diff) | |
download | text.love-aeaa7d150cacb5f858f1b516ca3e2234c68b8e55.tar.gz |
helper: file_exists
-rw-r--r-- | file.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/file.lua b/file.lua index 9440ae8..6b36b0f 100644 --- a/file.lua +++ b/file.lua @@ -1,4 +1,14 @@ -- primitives for saving to file and loading from file +function file_exists(filename) + local infile = App.open_for_reading(filename) + if infile then + infile:close() + return true + else + return false + end +end + function load_from_disk(State) local infile = App.open_for_reading(State.filename) State.lines = load_from_file(infile) |