Skip to content

[FEATURE] Replace tempdir() with R_user_dir() #302

Open
@agila5

Description

@agila5

The R 4.0.0 NEWS file says:

New function R_user_dir() in package tools suggests paths appropriate for storing R-related user-specific data, configuration and cache files.

For example, I currently see:

`tools::R_user_dir("osmextract", "data")`
#> [1] "C:\\Users\\user\\AppData\\Roaming/R/data/R/osmextract"

I think that the ideas behind this function are somewhat related to the approach we currently use to detect where osmextract functions will save .osm and .gpkg files, i.e.

osmextract/R/utils.R

Lines 72 to 78 in 0eeacf8

oe_download_directory = function() {
download_directory = Sys.getenv("OSMEXT_DOWNLOAD_DIRECTORY", tempdir())
if (!dir.exists(download_directory)) {
dir.create(download_directory) # nocov
}
normalizePath(download_directory)
}

Currently, we set the download directory as tempdir() whenever the OSMEXT_DOWNLOAD_DIRECTORY envvar is not set.

Does it make sense switching to tools::R_user_dir("osmextract", "data")?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions