---@diagnostic disable: duplicate-set-field require("core.platform.filesys") filesys.sep = "\\" ---Return a string representing the current working directory ---@return string function filesys.getcwd() local cwd, popen = "", io.popen local pfile, err = popen("cd") if not pfile or err ~= 0 then game.Log(tostring(filesys) .. ".getcwd() : popen failed executing " .. tostring(err), game.LOGGER_ERROR) return "" end cwd = pfile:read() or "" pfile:close() return cwd end local _normpath = filesys.normpath ---Normalize `path`, collapse redundant separators and up references ---@param path string ---@return string function filesys.normpath(path) path = _normpath(path) path = path:gsub("/", "\\") return path end ---Return a list of files and directory names in `path` ---@param path string ---@return string[] function filesys.scandir(path) local i, t, popen = 0, {}, io.popen local pfile, err = popen('dir "' .. path .. '" /b /ad') if not pfile or err ~= 0 then game.Log(tostring(filesys) .. ".scandir() : popen failed executing " .. tostring(err), game.LOGGER_ERROR) return {} end for filename in pfile:lines() do i = i + 1 t[i] = filename end pfile:close() return t end