Dear all,

I want to create a temporary directory from within my C++ R extension. On the other hand, CRAN's policy dictates that one cannot write anything outside the boundaries of the session's temporary directory, so I need to create it exactly there.

The R API offers R_tmpnam and R_tmpnam2, both of which require the path of the directory where the new name will reside. This can be obtained using tempdir() in R, but I couldn't find anything similar in the R API. Am I missing anything too obvious?

I tried out giving a NULL dirname to R_tmpnam{,2}, hoping that even though it's not mentioned in the docs, they would internally use the session's tmp dir, but this simply crashed. When embedding R one could also use the R_TempDir global variable, but this is flagged as unofficial R API for extensions. Finally, the only solution I could find was to call the tempdir() R function from within my C++ extension. This works fine, but it bothers me that there not an equivalent entry point in R's API.

Any pointers would be appreciated. If I'm deeply misunderstanding something please also shoot.

Cheers,

Rodrigo

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to