This generic function takes a directory and
file name then checks to make sure they exist.
The parameter check_mode
will also test to make sure
the file is readable (default) or writeable (check_mode = "write"
).
By default it will return an error if the file doesn't exist
but with create = TRUE
it will create an empty file with
appropriate permissions.
Usage
get_file_path(
directory,
file_name = NULL,
ext = NULL,
check_mode = "read",
create = NULL,
file_name_regexp = NULL,
selection_method = "modification_date"
)
Arguments
- directory
The file directory
- file_name
The file name (with extension if not supplied to
ext
)- ext
The extension (type of the file) - optional
- check_mode
The mode passed to
fs::file_access()
, defaults to "read" to check that you have read access to the file- create
Optionally create the file if it doesn't exists, the default is to only create a file if we set
check_mode = "write"
- file_name_regexp
A regular expression to search for the file name if this is used
file_name
should not be, it will return the most recently created file usingfind_latest_file()
- selection_method
Passed only to
find_latest_file()
, will select the file based on latest modification date (default) or file name
See also
Other file path functions:
get_dd_path()
,
get_demographic_cohorts_path()
,
get_homelessness_completeness_path()
,
get_ltcs_path()
,
get_nsu_path()
,
get_practice_details_path()
,
get_readcode_lookup_path()
,
get_service_use_cohorts_path()
,
get_sg_homelessness_pub_path()