File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1+ 2014-01-31 JJ Allaire <jj@rstudio.org>
2+
3+ * R/Attributes.R: Embedded R code chunks in sourceCpp are
4+ now executed within the working directory of the C++ source
5+ file.
6+
172014-01-31 Dirk Eddelbuettel <edd@debian.org>
28
39 * man/Rcpp.package.skeleton.Rd: Also updated
Original file line number Diff line number Diff line change @@ -24,12 +24,16 @@ sourceCpp <- function(file = "",
2424 showOutput = verbose ,
2525 verbose = getOption(" verbose" )) {
2626
27- # resolve code into a file if necessary
27+ # resolve code into a file if necessary. also track the working
28+ # directory to source the R embedded code chunk within
2829 if (! missing(code )) {
30+ rWorkingDir <- getwd()
2931 file <- tempfile(fileext = " .cpp" )
3032 con <- file(file , open = " w" )
3133 writeLines(code , con )
3234 close(con )
35+ } else {
36+ rWorkingDir <- dirname(file )
3337 }
3438
3539 # resolve the file path
@@ -167,6 +171,7 @@ sourceCpp <- function(file = "",
167171 # source the embeddedR
168172 if (length(context $ embeddedR ) > 0 ) {
169173 srcConn <- textConnection(context $ embeddedR )
174+ setwd(rWorkingDir ) # will be reset by previous on.exit handler
170175 source(file = srcConn , echo = TRUE )
171176 }
172177
Original file line number Diff line number Diff line change 2929 \item New \code {checkUserInterrupt()} function that provides a C ++ friendly
3030 implementation of \code {R_CheckUserInterrupt }.
3131 }
32+ \item Changes in Rcpp attributes :
33+ \itemize {
34+ \item Embedded R code chunks in sourceCpp are now executed within
35+ the working directory of the C ++ source file.
36+ }
3237 \item Changes in Rcpp documentation :
3338 \itemize {
3439 \item The Rcpp - FAQ and Rcpp - package vignettes have been updated and expanded.
You can’t perform that action at this time.
0 commit comments