Description Usage Arguments Details Value Examples
Given vectors of directories, basenames, and suffices,
find_config_files
combines them to find existing files.
1 2 | find_config_files(basenames = .basename.defaults(), dirs = .dir.defaults(),
suffices = .suffix.defaults())
|
basenames |
A vector of file names to use in searching for configuration files. |
dirs |
A vector of directory names to use in searching for configuration files. |
suffices |
A vector of suffices (file "type"s) to use in searching for the configuration file. |
This function is intended to support a variety of installation patterns, so
it attempts to be flexible in looking for configuration files. First,
environment variables of the form basename_CONFIG
, where
<basename> is the uppercase form of each candidate basename, are
examined to see whether any translate to a file path.
Following this, the path name parts supplied as arguments are used to
build potential file names. If dirs
is not specified, the
following directories are checked by default:
the user's $HOME
directory
the directory in which the executing script is located
the directory in which the calling function's calling function's source file is located (typically an application-level library)
the directory in which the calling function's source file is located
(typically a utility function, such as src_argos
)
. In each location, the file names given in basenames
are checked; if
not specified, several default file names are tried:
the name of the calling function's source file
the name of the executing script
the directory in which the calling function's calling function's source file is located (typically an application-level library)
. The suffices (file "type"s) of .json
, .conf
, and nothing,
are tried with each candidate path; you may override this default by
specifying suffices
. Finally, in order to accommodate the Unix
tradition of "hidden" configuration files, each basename is prefixed with
.
before tryng the basename alone.
A vector of path specifications
1 2 3 4 5 | find_config_files() # All defaults
find_config_files(dirs = c(file.path(Sys.getenv('HOME'),'etc'),
'/usr/local/etc', '/etc'),
basenames = c('my_app'),
suffices = c('.conf', '.rc'))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.