Skip to content

Commit 387194e

Browse files
committed
fixed exposeClass 'file' and 'Rfile' arguments to keep absolute path values even when fcn called from package root
1 parent 5cf50bc commit 387194e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

R/exposeClass.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ exposeClass <- function(class, constructors, fields, methods,
9292
}
9393
if(is.character(file)) {
9494
## are we in a package directory? Writable, searchable src subdirectory:
95-
if(file.access("src",3)==0)
95+
if(file.access("src",3)==0 && (basename(file) == file))
9696
cfile <- file.path("src", file)
9797
else
9898
cfile <- file
@@ -107,7 +107,7 @@ exposeClass <- function(class, constructors, fields, methods,
107107
if(identical(Rfile, TRUE))
108108
Rfile <- sprintf("%sClass.R",class)
109109
if(is.character(Rfile)) {
110-
if(file.access("R",3)==0) # in a package directory
110+
if(file.access("R",3)==0 && (basename(file) == file)) # in a package directory
111111
Rfile <- file.path("R", Rfile)
112112
Rcon <- file(Rfile, "w")
113113
msg <- sprintf("Wrote R file \"%s\"",Rfile)
@@ -200,11 +200,11 @@ exposeClass <- function(class, constructors, fields, methods,
200200
if(missing(CppClass))
201201
CppString <- ""
202202
else
203-
CppString <- paste(",",dQuote(CppClass))
203+
CppString <- paste0(", \"",CppClass, "\"")
204204
if(missing(module))
205205
ModString <- ""
206206
else
207-
ModString <- paste(", module =", dQuote(module))
207+
ModString <- paste0(", module = \"", module, "\"")
208208
writeLines(sprintf("%s <- setRcppClass(\"%s\"%s%s)",
209209
class, class, CppString,ModString), Rcon)
210210
}

0 commit comments

Comments
 (0)