diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-01-13 16:01:06 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-01-13 16:01:06 +0000 |
commit | 77f10141386c423248bb07a5b4ce794ad9aca138 (patch) | |
tree | e4cd74210c8209fd474abc1b98efb2c1744c45c5 | |
parent | 3f943fda69400d230ff78b19f1739a30fa154961 (diff) | |
download | acf-shorewall-77f10141386c423248bb07a5b4ce794ad9aca138.tar.bz2 acf-shorewall-77f10141386c423248bb07a5b4ce794ad9aca138.tar.xz |
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
-rw-r--r-- | shorewall-model.lua | 6 |
1 files 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 |