Add new key-value pair to end of section. Error if key already exists.
Example:
# Example for ini_add_key
write_file("/tmp/za_ini_add.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_add.ini")
ini_add_key(cfg, "section", "newkey", "newval")
Add new key-value pair with inline comment to end of section. Error if key already exists.
Example:
# Example for ini_add_key_with_comment
write_file("/tmp/za_ini_ac.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_ac.ini")
ini_add_key_with_comment(cfg, "section", "newkey", "newval", "comment")
Delete key from section. Error if key doesn't exist.
Example:
# Example for ini_delete_key
write_file("/tmp/za_ini_dk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_dk.ini")
ini_delete_key(cfg, "section", "key")
Delete section by name and renumber remaining sections.
Example:
# Example for ini_delete_section
write_file("/tmp/za_ini_ds.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_ds.ini")
ini_delete_section(cfg, "section")
Get global section entries (before any [section] header).
Example:
# Example for ini_get_global
write_file("/tmp/za_ini.ini", "key=val\n")
cfg = ini_read("/tmp/za_ini.ini")
ini_get_global(cfg)
Get value of specific key in section. Error if key doesn't exist.
Example:
# Example for ini_get_key
write_file("/tmp/za_ini_gk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_gk.ini")
ini_get_key(cfg, "section", "key")
Get all entries in section including metadata. Error if section doesn't exist.
Example:
# Example for ini_get_section
write_file("/tmp/za_ini_gs.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_gs.ini")
ini_get_section(cfg, "section")
Check if key exists in section. Returns true if found, false otherwise.
Example:
# Example for ini_has_key
write_file("/tmp/za_ini_hk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_hk.ini")
ini_has_key(cfg, "section", "key")
Insert section at position (1-indexed, 0=prepend) and renumber.
Example:
# Example for ini_insert_section
write_file("/tmp/za_ini_is.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_is.ini")
ini_insert_section(cfg, "newsection", 1)
Get array of all key names in section. Error if section doesn't exist.
Example:
# Example for ini_list_keys
write_file("/tmp/za_ini_lk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_lk.ini")
ini_list_keys(cfg, "section")
Renumber section orders in map to ensure sequential consistency.
Example:
# Example for ini_meta_update
write_file("/tmp/za_ini_mu.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_mu.ini")
ini_meta_update(cfg)
Append new section at end of order and renumber.
Example:
# Example for ini_new_section
write_file("/tmp/za_ini_ns.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_ns.ini")
ini_new_section(cfg, "newsection")
Read an INI file and return a map of sections. Empty string key is global section.
Example:
# Example for ini_read
write_file("/tmp/za_test.ini", "[section]\nkey=val\n")
ini_read("/tmp/za_test.ini")
Set global section entries.
Example:
# Example for ini_set_global
write_file("/tmp/za_ini.ini", "key=val\n")
cfg = ini_read("/tmp/za_ini.ini")
ini_set_global(cfg, [])
Update existing key value. Preserves inline comments. Error if key doesn't exist.
Example:
# Example for ini_set_key
write_file("/tmp/za_ini_sk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_sk.ini")
ini_set_key(cfg, "section", "key", "newval")
Replace entire section with new entries array. Error if section doesn't exist.
Example:
# Example for ini_set_section
write_file("/tmp/za_ini_ss.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_ss.ini")
ini_set_section(cfg, "section", [])
Write an INI map to file. Preserves comments and formatting.
Example:
# Example for ini_write
write_file("/tmp/za_ini_w.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_w.ini")
ini_write(cfg, "/tmp/za_ini_w_out.ini")