file
content as ININew properties will be appended to the self
, existing properties will be
overwrote by the values contained in file
.
var ini = new IniFile
ini["key1"] = "value1"
ini["key2"] = "value2"
"""
key2=changed
key3=added
""".write_to_file("load_config.ini")
ini.load_file("load_config.ini")
assert ini["key1"] == "value1"
assert ini["key2"] == "changed"
assert ini["key3"] == "added"
"load_config.ini".to_path.delete
The process fails silently if the file does not exist.
ini = new IniFile
ini.load_file("ini_not_found.ini")
assert ini.is_empty
Returns true
if the parsing finished correctly.
See also stop_on_first_error
and errors
.
# Load a `file` content as INI
#
# New properties will be appended to the `self`, existing properties will be
# overwrote by the values contained in `file`.
#
# ~~~
# var ini = new IniFile
# ini["key1"] = "value1"
# ini["key2"] = "value2"
#
# """
# key2=changed
# key3=added
# """.write_to_file("load_config.ini")
#
# ini.load_file("load_config.ini")
# assert ini["key1"] == "value1"
# assert ini["key2"] == "changed"
# assert ini["key3"] == "added"
#
# "load_config.ini".to_path.delete
# ~~~
#
# The process fails silently if the file does not exist.
#
# ~~~
# ini = new IniFile
# ini.load_file("ini_not_found.ini")
# assert ini.is_empty
# ~~~
#
# Returns `true` if the parsing finished correctly.
#
# See also `stop_on_first_error` and `errors`.
fun load_file(file: String): Bool do return load_string(file.to_path.read_all)
lib/ini/ini.nit:401,2--435,79