Skip to content
Prev 2507 / 12125 Next

[R-pkg-devel] Dealing with not so temporary files

This seems to be a good occasion to note that the CRAN policy does not
seem to conform
the industry standards. Applications can actually store user level
configuration information,
cached data, logs, etc. in the user's home directory, and there
standard way to do this.

Here is the Apple recommendation:
https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW1

AFAIK all modern Linux distributions use the XDG standard, or
something close to it:
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

On Windows there are APIs to retrieve the right locations, but
generally it is all in
`%APPDATA%`: https://msdn.microsoft.com/en-us/library/dd378457(v=vs.85).aspx

The rappdirs package helps you to select the right location, in a
platform independent way.
Of course according to the CRAN policy, you still need to ask the user
interactively
before writing to the directories that rappdirs returns.

I think a good practice is to use "R" as the application name, and
within that a subdirectory
that is the package name. This is a way to do it, for configuration files:

## Windows
? rappdirs::user_config_dir("R", version = "mypackage")
[1] "C:/Users/gaborcsardi/AppData/R/R/mypackage"

## macOS
? rappdirs::user_config_dir("R", version = "mypackage")
[1] "/Users/gaborcsardi/Library/Application Support/R/mypackage"

## Linux
? rappdirs::user_config_dir("R", version = "mypackage", os = "unix")
[1] "/Users/gaborcsardi/.config/R/mypackage"

Gabor
On Tue, Mar 13, 2018 at 8:52 AM, Joris Meys <Joris.Meys at ugent.be> wrote: