From 77f10141386c423248bb07a5b4ce794ad9aca138 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 13 Jan 2009 16:01:06 +0000 Subject: Modified fs.lua to survive nil parameters. Added create_directory and used within create_file and write_file. Reviewed each read_file call to make sure handles nil return value. git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed --- shorewall-model.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shorewall-model.lua b/shorewall-model.lua index dd7a864..d7682ab 100644 --- a/shorewall-model.lua +++ b/shorewall-model.lua @@ -21,7 +21,7 @@ local function read_config(file) if not (fs.is_file(path)) then return {} end - local filecontent = fs.read_file_as_array(path) + local filecontent = fs.read_file_as_array(path) or {} local output = {} for k,v in pairs(filecontent) do if not string.find ( v, "^[;#].*" ) and not (string.find (v, "^%s*$")) then @@ -62,7 +62,7 @@ local function addremove_config( addremove, file, value, orgvalue ) }) end - local filecontentarray = fs.read_file_as_array(filepath) + local filecontentarray = fs.read_file_as_array(filepath) or {} if (addremove == "delete" ) then local modifyrow @@ -200,7 +200,7 @@ function configcheck () end function getlogfile () - local logfilepath = format.parse_ini_file(fs.read_file(configfile),"","LOGFILE") or "" + local logfilepath = format.parse_ini_file(fs.read_file(configfile) or "","","LOGFILE") or "" return cfe({ value=logfilepath, label="Shorewall logfile" }) end -- cgit v1.2.3