Description Arguments Details Examples
Parse a .ini or a .cfg file
path |
(character) A single file path to read from on initialize, or
to write to on |
Methods
read()
Read a file
write(path)
Write a file - path: path to write the file to
get(x, fallback)
Get a section - x: section name to get - fallback: (character) fallback value if 'x' not found
sections()
Get all sections of a file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## Not run:
# example file
gitfile <- system.file("examples", "gitconfig.ini", package = "inir")
# instantiate new object with file path
(res <- ini(gitfile))
# get file path
res$file
# read file
res$read()
# get section names
res$sections()
# get contents of a single section
res$get("core")
## or index to it via the "parsed" element
res$parsed$gitconfig.ini[['core']]
# another example getting a section
res$get('remote "origin"')
res$parsed$gitconfig.ini[['remote "origin"']]
# You can set a default value with the get() method
res$get("stuff") # returns NULL
res$get("stuff", "hello_world") # default value
# write file
res$write(path = "myfile2.ini")
unlink("myfile2.ini")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.