|
@@ -1,7 +1,7 @@
|
|
|
-- ===================================================================
|
|
|
-- Overview.
|
|
|
|
|
|
--- This file is "top/ocutil.lua".
|
|
|
+-- This file is "top/modpol.ocutil.lua".
|
|
|
|
|
|
-- This file provides a collection of largely portable Lua utility
|
|
|
-- functions. The collection is descended from one assembled by Old-
|
|
@@ -9,15 +9,15 @@
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil = {}
|
|
|
+modpol.ocutil = {}
|
|
|
|
|
|
-ocutil.log_console = true -- Flag: Copy log to console
|
|
|
-ocutil.logdir = nil -- Absolute path for log-file direc-
|
|
|
+modpol.ocutil.log_console = true -- Flag: Copy log to console
|
|
|
+modpol.ocutil.logdir = nil -- Absolute path for log-file direc-
|
|
|
-- tory (or nil)
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.fixnil
|
|
|
+-- Function: modpol.ocutil.fixnil
|
|
|
-- Params: string s
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -30,7 +30,7 @@ ocutil.logdir = nil -- Absolute path for log-file direc-
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.fixnil = function (s)
|
|
|
+modpol.ocutil.fixnil = function (s)
|
|
|
if s == nil then s = "(nil)"
|
|
|
elseif s == "" then s = "(empty)"
|
|
|
end
|
|
@@ -39,46 +39,46 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.setlogdir
|
|
|
+-- Function: modpol.ocutil.setlogdir
|
|
|
-- Params: string path
|
|
|
-- Outputs:
|
|
|
--
|
|
|
-- The input string should be the absolute path for a writable direc-
|
|
|
--- tory that already exists. This function tells "ocutil.log" to put
|
|
|
+-- tory that already exists. This function tells "modpol.ocutil.log" to put
|
|
|
-- log files in that directory.
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.setlogdir = function (path)
|
|
|
+modpol.ocutil.setlogdir = function (path)
|
|
|
if path ~= nil and path ~= "" then
|
|
|
- ocutil.logdir = path
|
|
|
+ modpol.ocutil.logdir = path
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.setlogname
|
|
|
+-- Function: modpol.ocutil.setlogname
|
|
|
-- Params: string name
|
|
|
-- Outputs:
|
|
|
--
|
|
|
-- The input string should be a filename without a path component.
|
|
|
--- This function tells "ocutil.log" to use the specified filename for
|
|
|
+-- This function tells "modpol.ocutil.log" to use the specified filename for
|
|
|
-- the main log file.
|
|
|
--
|
|
|
--- "ocutil.setlogdir" must be called separately to set the log-file
|
|
|
+-- "modpol.ocutil.setlogdir" must be called separately to set the log-file
|
|
|
-- directory.
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.setlogname = function (name)
|
|
|
+modpol.ocutil.setlogname = function (name)
|
|
|
if name ~= nil and name ~= "" then
|
|
|
- ocutil.logname = name
|
|
|
+ modpol.ocutil.logname = name
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.log
|
|
|
+-- Function: modpol.ocutil.log
|
|
|
-- Params: string s
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -87,26 +87,26 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.log = function (s)
|
|
|
- s = ocutil.fixnil (s)
|
|
|
+modpol.ocutil.log = function (s)
|
|
|
+ s = modpol.ocutil.fixnil (s)
|
|
|
s = s:gsub ("\n$", "", 1) -- Remove trailing newline initially
|
|
|
|
|
|
- if ocutil.log_console then
|
|
|
+ if modpol.ocutil.log_console then
|
|
|
print (s)
|
|
|
end
|
|
|
|
|
|
- if ocutil.logdir ~= nil and
|
|
|
- ocutil.logname ~= nil then
|
|
|
+ if modpol.ocutil.logdir ~= nil and
|
|
|
+ modpol.ocutil.logname ~= nil then
|
|
|
s = s .. "\n" -- Add trailing newline
|
|
|
|
|
|
- local logpath = ocutil.logdir .. "/" .. ocutil.logname
|
|
|
- ocutil.file_append (logpath, s)
|
|
|
+ local logpath = modpol.ocutil.logdir .. "/" .. modpol.ocutil.logname
|
|
|
+ modpol.ocutil.file_append (logpath, s)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.fatal_error
|
|
|
+-- Function: modpol.ocutil.fatal_error
|
|
|
-- Params: string s
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -115,15 +115,15 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.fatal_error = function (s)
|
|
|
- ocutil.log ("Fatal Error: " .. s)
|
|
|
+modpol.ocutil.fatal_error = function (s)
|
|
|
+ modpol.ocutil.log ("Fatal Error: " .. s)
|
|
|
os.exit (1)
|
|
|
return nil -- Shouldn't be reached
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.panic
|
|
|
+-- Function: modpol.ocutil.panic
|
|
|
-- Params: string s
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -132,15 +132,15 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.panic = function (s)
|
|
|
- ocutil.log ("Internal Error: " .. s)
|
|
|
+modpol.ocutil.panic = function (s)
|
|
|
+ modpol.ocutil.log ("Internal Error: " .. s)
|
|
|
os.exit (1)
|
|
|
return nil -- Shouldn't be reached
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.str_empty
|
|
|
+-- Function: modpol.ocutil.str_empty
|
|
|
-- Params: string x
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -149,7 +149,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.str_empty = function (x)
|
|
|
+modpol.ocutil.str_empty = function (x)
|
|
|
if x == nil or x == "" then
|
|
|
return true
|
|
|
else
|
|
@@ -159,7 +159,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.str_nonempty
|
|
|
+-- Function: modpol.ocutil.str_nonempty
|
|
|
-- Params: string x
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -168,7 +168,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.str_nonempty = function (x)
|
|
|
+modpol.ocutil.str_nonempty = function (x)
|
|
|
if x == nil or x == "" then
|
|
|
return false
|
|
|
else
|
|
@@ -178,7 +178,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.table_empty
|
|
|
+-- Function: modpol.ocutil.table_empty
|
|
|
-- Params: table tab
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -187,7 +187,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.table_empty = function (tab)
|
|
|
+modpol.ocutil.table_empty = function (tab)
|
|
|
local next = next
|
|
|
if next (tab) == nil then return true end
|
|
|
return false
|
|
@@ -195,7 +195,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.table_nonempty
|
|
|
+-- Function: modpol.ocutil.table_nonempty
|
|
|
-- Params: table tab
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -204,14 +204,14 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.table_nonempty = function (tab)
|
|
|
- if ocutil.table_empty (tab) then return false end
|
|
|
+modpol.ocutil.table_nonempty = function (tab)
|
|
|
+ if modpol.ocutil.table_empty (tab) then return false end
|
|
|
return true
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.string_contains
|
|
|
+-- Function: modpol.ocutil.string_contains
|
|
|
-- Params: strings a, b
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -220,7 +220,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.str_contains = function (a, b)
|
|
|
+modpol.ocutil.str_contains = function (a, b)
|
|
|
if string.match (a, b) then
|
|
|
return true
|
|
|
else
|
|
@@ -230,7 +230,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.str_false
|
|
|
+-- Function: modpol.ocutil.str_false
|
|
|
-- Params: string x
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -240,7 +240,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.str_false = function (x)
|
|
|
+modpol.ocutil.str_false = function (x)
|
|
|
if x == "false" or x == "no" or
|
|
|
x == "off" or x == "0" or
|
|
|
x == false or x == 0 then
|
|
@@ -252,7 +252,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.str_true
|
|
|
+-- Function: modpol.ocutil.str_true
|
|
|
-- Params: string x
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -262,7 +262,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.str_true = function (x)
|
|
|
+modpol.ocutil.str_true = function (x)
|
|
|
if x == "true" or x == "yes" or
|
|
|
x == "on" or x == "1" or
|
|
|
x == true or x == 1 then
|
|
@@ -274,7 +274,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.starts_with
|
|
|
+-- Function: modpol.ocutil.starts_with
|
|
|
-- Params: strings String, Start
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -283,7 +283,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.starts_with = function (String, Start)
|
|
|
+modpol.ocutil.starts_with = function (String, Start)
|
|
|
if string.sub (String, 1, string.len (Start)) == Start then
|
|
|
return true
|
|
|
else
|
|
@@ -293,7 +293,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.not_starts_with
|
|
|
+-- Function: modpol.ocutil.not_starts_with
|
|
|
-- Params: strings String, Start
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -302,7 +302,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.not_starts_with = function (String, Start)
|
|
|
+modpol.ocutil.not_starts_with = function (String, Start)
|
|
|
if string.sub (String, 1, string.len (Start)) == Start then
|
|
|
return false
|
|
|
else
|
|
@@ -312,7 +312,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.ends_with
|
|
|
+-- Function: modpol.ocutil.ends_with
|
|
|
-- Params: strings String, End
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -322,14 +322,14 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.ends_with = function (String, End)
|
|
|
+modpol.ocutil.ends_with = function (String, End)
|
|
|
return End == '' or string.sub (String,
|
|
|
-string.len (End)) == End
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.not_ends_with
|
|
|
+-- Function: modpol.ocutil.not_ends_with
|
|
|
-- Params: strings String, End
|
|
|
-- Outputs:
|
|
|
-- Returns false if the 1st string ends with the 2nd one
|
|
@@ -338,8 +338,8 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.not_ends_with = function (String, End)
|
|
|
- if ocutil.ends_with (String, End) then
|
|
|
+modpol.ocutil.not_ends_with = function (String, End)
|
|
|
+ if modpol.ocutil.ends_with (String, End) then
|
|
|
return false
|
|
|
else
|
|
|
return true
|
|
@@ -348,33 +348,33 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.firstch
|
|
|
+-- Function: modpol.ocutil.firstch
|
|
|
-- Params: string str
|
|
|
-- Outputs:
|
|
|
-- Returns the 1st character of the string
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.firstch = function (str)
|
|
|
+modpol.ocutil.firstch = function (str)
|
|
|
return string.sub (str, 1, 1)
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.first_to_upper
|
|
|
+-- Function: modpol.ocutil.first_to_upper
|
|
|
-- Params: string str
|
|
|
-- Outputs:
|
|
|
-- Returns the 1st character of the string in upper case
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.first_to_upper = function (str)
|
|
|
+modpol.ocutil.first_to_upper = function (str)
|
|
|
return (str:gsub ("^%l", string.upper))
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.all_first_to_upper
|
|
|
+-- Function: modpol.ocutil.all_first_to_upper
|
|
|
-- Params: string str, flag cvtspace
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -385,13 +385,13 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.all_first_to_upper = function (str, cvtspace)
|
|
|
+modpol.ocutil.all_first_to_upper = function (str, cvtspace)
|
|
|
|
|
|
str = str:gsub ("^%l", string.upper)
|
|
|
str = str:gsub ("[_ ]%l",
|
|
|
function (a) return string.upper (a) end)
|
|
|
|
|
|
- if ocutil.str_true (cvtspace) then
|
|
|
+ if modpol.ocutil.str_true (cvtspace) then
|
|
|
str = str:gsub ("_", " ")
|
|
|
end
|
|
|
|
|
@@ -400,7 +400,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.strtok
|
|
|
+-- Function: modpol.ocutil.strtok
|
|
|
-- Params: strings source, delimitch
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -413,7 +413,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.strtok = function (source, delimitch)
|
|
|
+modpol.ocutil.strtok = function (source, delimitch)
|
|
|
if delimitch == nil or
|
|
|
delimitch == "" then delimitch = " " end
|
|
|
|
|
@@ -432,7 +432,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.swap_key_value
|
|
|
+-- Function: modpol.ocutil.swap_key_value
|
|
|
-- Params: table itable
|
|
|
-- Outputs:
|
|
|
-- Turns keys into values and vice versa and returns the resulting
|
|
@@ -440,7 +440,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.swap_key_value = function (itable)
|
|
|
+modpol.ocutil.swap_key_value = function (itable)
|
|
|
if itable == nil then return nil end
|
|
|
local otable = {}
|
|
|
for key, value in pairs (itable) do otable [value] = key end
|
|
@@ -449,7 +449,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.ktable_to_vtable
|
|
|
+-- Function: modpol.ocutil.ktable_to_vtable
|
|
|
-- Params: table ktable
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -476,7 +476,7 @@ end
|
|
|
-- print (ii .. ") " .. tabby [ii])
|
|
|
-- end
|
|
|
--
|
|
|
--- tabby = ocutil.ktable_to_vtable (tabby)
|
|
|
+-- tabby = modpol.ocutil.ktable_to_vtable (tabby)
|
|
|
--
|
|
|
-- print ("\nOutput table:")
|
|
|
-- for ii, value in ipairs (tabby) do
|
|
@@ -485,7 +485,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.ktable_to_vtable = function (ktable)
|
|
|
+modpol.ocutil.ktable_to_vtable = function (ktable)
|
|
|
local vtable = {}
|
|
|
if ktable == nil then return vtable end
|
|
|
|
|
@@ -499,7 +499,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.vtable_to_ktable
|
|
|
+-- Function: modpol.ocutil.vtable_to_ktable
|
|
|
-- Params: table vtable, scalar set_to
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -524,7 +524,7 @@ end
|
|
|
-- print (ii .. ") " .. tabby [ii])
|
|
|
-- end
|
|
|
--
|
|
|
--- tabby = ocutil.vtable_to_ktable (tabby, 42)
|
|
|
+-- tabby = modpol.ocutil.vtable_to_ktable (tabby, 42)
|
|
|
--
|
|
|
-- print ("\nOutput table:")
|
|
|
-- for ii, value in pairs (tabby) do
|
|
@@ -533,7 +533,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.vtable_to_ktable = function (vtable, set_to)
|
|
|
+modpol.ocutil.vtable_to_ktable = function (vtable, set_to)
|
|
|
|
|
|
local ktable = {}
|
|
|
if vtable == nil then return ktable end
|
|
@@ -548,7 +548,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.make_set
|
|
|
+-- Function: modpol.ocutil.make_set
|
|
|
-- Params: array harry
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -559,12 +559,12 @@ end
|
|
|
-- Here's a complete code fragment which demonstrates operation of
|
|
|
-- this function:
|
|
|
--
|
|
|
--- local color_set = ocutil.make_set { "red", "green", "blue" }
|
|
|
+-- local color_set = modpol.ocutil.make_set { "red", "green", "blue" }
|
|
|
-- if color_set ["red"] ~= nil then print ("Supported color") end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.make_set = function (list)
|
|
|
+modpol.ocutil.make_set = function (list)
|
|
|
local set = {}
|
|
|
for _, l in ipairs (list) do set [l] = true end
|
|
|
return set
|
|
@@ -572,7 +572,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.pos_to_str
|
|
|
+-- Function: modpol.ocutil.pos_to_str
|
|
|
-- Params: position-table pos
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -583,13 +583,13 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.pos_to_str = function (pos)
|
|
|
+modpol.ocutil.pos_to_str = function (pos)
|
|
|
return pos.x .. "," .. pos.y .. "," .. pos.z
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.table_length
|
|
|
+-- Function: modpol.ocutil.table_length
|
|
|
-- Params: table tabby
|
|
|
-- Outputs: Returns number of entries in table
|
|
|
--
|
|
@@ -598,7 +598,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.table_length = function (tabby)
|
|
|
+modpol.ocutil.table_length = function (tabby)
|
|
|
local count = 0
|
|
|
for _ in pairs (tabby) do count = count+1 end
|
|
|
return count
|
|
@@ -606,7 +606,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.clone_table
|
|
|
+-- Function: modpol.ocutil.clone_table
|
|
|
-- Params: table tabby
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -614,25 +614,25 @@ end
|
|
|
-- should work correctly for most cases, but special cases that re-
|
|
|
-- quire additional work may exist.
|
|
|
--
|
|
|
--- This function may also be called as "ocutil.table_clone".
|
|
|
+-- This function may also be called as "modpol.ocutil.table_clone".
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.clone_table = function (tabby)
|
|
|
+modpol.ocutil.clone_table = function (tabby)
|
|
|
if tabby == nil then return nil end
|
|
|
local copy = {}
|
|
|
for k, v in pairs (tabby) do
|
|
|
- if type (v) == 'table' then v = ocutil.clone_table (v) end
|
|
|
+ if type (v) == 'table' then v = modpol.ocutil.clone_table (v) end
|
|
|
copy [k] = v
|
|
|
end
|
|
|
return copy
|
|
|
end
|
|
|
|
|
|
-ocutil.table_clone = ocutil.clone_table
|
|
|
+modpol.ocutil.table_clone = modpol.ocutil.clone_table
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.file_exists
|
|
|
+-- Function: modpol.ocutil.file_exists
|
|
|
-- Params: string path
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -642,7 +642,7 @@ ocutil.table_clone = ocutil.clone_table
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.file_exists = function (path)
|
|
|
+modpol.ocutil.file_exists = function (path)
|
|
|
local file, err
|
|
|
file, err = io.open (path, "rb")
|
|
|
if err then return false end
|
|
@@ -652,7 +652,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.file_missing
|
|
|
+-- Function: modpol.ocutil.file_missing
|
|
|
-- Params: string path
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -662,14 +662,14 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.file_missing = function (path)
|
|
|
- if ocutil.file_exists (path) then return false end
|
|
|
+modpol.ocutil.file_missing = function (path)
|
|
|
+ if modpol.ocutil.file_exists (path) then return false end
|
|
|
return true
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.file_read
|
|
|
+-- Function: modpol.ocutil.file_read
|
|
|
-- Params: string path
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -681,7 +681,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.file_read = function (path)
|
|
|
+modpol.ocutil.file_read = function (path)
|
|
|
local file, err
|
|
|
file, err = io.open (path, "rb")
|
|
|
if err then return nil end
|
|
@@ -692,7 +692,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.file_write
|
|
|
+-- Function: modpol.ocutil.file_write
|
|
|
-- Params: strings path, data
|
|
|
-- Outputs:
|
|
|
--
|
|
@@ -707,7 +707,7 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.file_write = function (path, data)
|
|
|
+modpol.ocutil.file_write = function (path, data)
|
|
|
local file, err
|
|
|
file, err = io.open (path, "wb")
|
|
|
if err then return false end
|
|
@@ -719,17 +719,17 @@ end
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
--- Function: ocutil.file_append
|
|
|
+-- Function: modpol.ocutil.file_append
|
|
|
-- Params: strings path, data
|
|
|
-- Outputs:
|
|
|
--
|
|
|
--- This function is identical to "ocutil.file_write" except for one
|
|
|
+-- This function is identical to "modpol.ocutil.file_write" except for one
|
|
|
-- difference: It appends to existing files as opposed to overwrites
|
|
|
-- them.
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
-ocutil.file_append = function (path, data)
|
|
|
+modpol.ocutil.file_append = function (path, data)
|
|
|
local file, err
|
|
|
file, err = io.open (path, "ab")
|
|
|
if err then return false end
|