Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
agila5 opened this issue Nov 7, 2024 · 1 comment
Open

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

agila5 opened this issue Nov 7, 2024 · 1 comment

Comments

@agila5
Copy link
Collaborator

agila5 commented Nov 7, 2024

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")?

@Robinlovelace
Copy link
Member

Cool! Yes could make sense to use that if there is now env var.

@agila5 agila5 changed the title [FEATURE] [FEATURE] Replace tempdir() with R_user_dir() Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants