From 5734f776f166b9fdf0f1a2d21227bf7ee6ed14b4 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/opennhrp/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed --- opennhrp-model.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'opennhrp-model.lua') diff --git a/opennhrp-model.lua b/opennhrp-model.lua index 78338f9..36c3480 100644 --- a/opennhrp-model.lua +++ b/opennhrp-model.lua @@ -193,7 +193,7 @@ function getinterfacedetails(interface) details.type = cfe({ type="select", value="Unused", label="Interface type", option={"Unused", "NHRP Enabled", "Shortcut Destination"} }) details.map = cfe({ type="list", value={}, label="Static Peers", descr="List of static peer mappings of protocol-address to nbma-address. Optional 'register' parameter specifies Registration Request sent to this peer on startup. (protocol-address[/prefix] nbma-address [register])" }) - configfilecontent = configfilecontent or fs.read_file(configfile) + configfilecontent = configfilecontent or fs.read_file(configfile) or "" config = config or parseconfigfile(configfilecontent) if config and config[interface] then if config[interface]["shortcut-destination"] then @@ -214,7 +214,7 @@ function updateinterfacedetails(interfacedetails) local success, interfacedetails = validateinterfacedetails(interfacedetails) if success then - configfilecontent = configfilecontent or fs.read_file(configfile) + configfilecontent = configfilecontent or fs.read_file(configfile) or "" local startchar = string.find(configfilecontent or "", "interface%s+"..interfacedetails.value.interface.value) local lines = {} if startchar then @@ -263,7 +263,7 @@ end function listinterfaces(self) local interfaces = {} list_interfaces(self) - configfilecontent = configfilecontent or fs.read_file(configfile) + configfilecontent = configfilecontent or fs.read_file(configfile) or "" config = config or parseconfigfile(configfilecontent) for name,intf in pairs(config) do temp = {interface=name, type="NHRP Enabled", errtxt=intf.errtxt} -- cgit v1.2.3