- file.copy(file.path(R.home("share"), "texmf", "tex", "latex", "Sweave.sty"),
- dirname(.cmdargs[2]), overwrite=TRUE)
+ .texmf.path <- file.path(R.home("share"), "texmf")
+ if (!file.exists(.sweave.sty <- file.path(.texmf.path, "Sweave.sty"))) {
+ .sweave.sty <- file.path(.texmf.path, "tex", "latex", "Sweave.sty")
+ }
+ file.copy(.sweave.sty, dirname(.cmdargs[2]), overwrite=TRUE)
+ rm(list = c('.sweave.sty', '.texmf.path'))