summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-01-13 16:01:06 +0000
committerTed Trask <ttrask01@yahoo.com>2009-01-13 16:01:06 +0000
commit21db17697487d4476e7f521b87b8e88fb61f9672 (patch)
treed64e4ac371d27ab83f17ededd81e989ffbc89c6f
parent3b346d6835d8276b897d41cf89756f20a2111c9a (diff)
downloadacf-tinydns-21db17697487d4476e7f521b87b8e88fb61f9672.tar.bz2
acf-tinydns-21db17697487d4476e7f521b87b8e88fb61f9672.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/tinydns/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--tinydns-model.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/tinydns-model.lua b/tinydns-model.lua
index b17f8e2..0fa92f1 100644
--- a/tinydns-model.lua
+++ b/tinydns-model.lua
@@ -52,7 +52,7 @@ local descr = {
-- Commented/Blank lines are ignored
local function get_value_from_file(file)
local output = {}
- local filecontent = fs.read_file_as_array(file)
+ local filecontent = fs.read_file_as_array(file) or {}
for i=1,table.maxn(filecontent) do
local l = filecontent[i]
if not (string.find ( l, "^[;#].*" )) and not (string.find (l, "^%s*$")) then
@@ -168,7 +168,7 @@ end
function getconfig()
local config = {}
- local listenaddr = format.parse_ini_file(fs.read_file(configfile),"","IP") or ""
+ local listenaddr = format.parse_ini_file(fs.read_file(configfile) or "","","IP") or ""
config.listen = cfe({
label="IP address to listen on",
value=listenaddr,
@@ -201,7 +201,7 @@ function getconfigobjects(self, file_name, userid, filter_type)
--Loop through all available configfiles
for i,filename in pairs(configfiles) do
if not file_name or file_name == filename then
- local filecontent = fs.read_file_as_array(filename)
+ local filecontent = fs.read_file_as_array(filename) or {}
for linenumber,configline in ipairs(filecontent) do
local domaindetails = {}
local filecontent_table = split_config_items(configline)