From 0d06958516a3b114469314c9dca00cbb017b220d Mon Sep 17 00:00:00 2001 From: Saif Almansoori Date: Fri, 12 Jun 2026 04:31:22 +0400 Subject: [PATCH] Support running in Linux and macOS --- main.lua | 6 +++++- parser.lua | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/main.lua b/main.lua index af8aec1..dd6f0cb 100644 --- a/main.lua +++ b/main.lua @@ -5,11 +5,15 @@ local serpent = require('serpent') local generator = require('generator') -- local lfs = require("lfs") local DIR_SEP = '/' +local IS_WINDOWS = package.config:sub(1, 1) == '\\' local function getFileList(path) local i, t, popen = 0, {}, io.popen - for filename in popen('dir "' .. path .. '" /b'):lines() do + local cmd = IS_WINDOWS + and ('dir "' .. path .. '" /b') + or ('ls -1 "' .. path .. '"') + for filename in popen(cmd):lines() do i = i + 1 t[i] = path .. DIR_SEP .. filename end diff --git a/parser.lua b/parser.lua index 44010a2..150674b 100644 --- a/parser.lua +++ b/parser.lua @@ -73,6 +73,12 @@ local function extractInfo(filename) local inOverview = false local f = io.open(filename, 'r') if f == nil then return end + -- On Windows io.open fails on a directory, but on Unix it succeeds and only + -- f:lines() errors with "Is a directory". Detect that case and bail out. + if f:read(0) == nil then + f:close() + return + end for l in f:lines() do i = i + 1 if l:find("^> __Parent__") then