Commit 81775e43 authored by Ted Trask's avatar Ted Trask

Modified fs.lua to survive nil parameters. Added create_directory and used...

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/dansguardian/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
parent 98522bd4
......@@ -27,7 +27,7 @@ local categoryfiles = {
local function get_includes_from_file(file)
local retval = {}
for k,v in pairs(fs.read_file_as_array(file)) do
for k,v in pairs(fs.read_file_as_array(file) or {}) do
if (string.match(v, '^%s*.Include')) then
local val = string.match(v,'^%s*.Include<(.*)>%s*')
retval[val] = true
......@@ -95,7 +95,7 @@ read_general_config = function()
naughtynesslimit = cfe({ label="NaughtynessLimit" })
}
local config = format.parse_ini_file(fs.read_file(dansguardiancfg), "")
local config = format.parse_ini_file(fs.read_file(dansguardiancfg) or "", "")
if config then
if config.filterip then retval.filterip.value = config.filterip end
if config.filterport then retval.filterport.value = config.filterport end
......@@ -104,7 +104,7 @@ read_general_config = function()
if config.accessdeniedaddress then retval.accessdeniedaddress.value = string.sub(config.accessdeniedaddress, 2, -2) end
end
config = format.parse_ini_file(fs.read_file(dansguardiancfg2), "")
config = format.parse_ini_file(fs.read_file(dansguardiancfg2) or "", "")
if config then
if config.naughtynesslimit then retval.naughtynesslimit.value = config.naughtynesslimit end
end
......@@ -248,7 +248,7 @@ get_category = function(category, object)
})
retval.filecontent = cfe({
label="Filename",
value=fs.read_file(filename),
value=fs.read_file(filename) or "",
type="longtext",
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment