1
|
|
###########################################################################/**
|
2
|
|
# @RdocDefault compileRsp
|
3
|
|
#
|
4
|
|
# @title "Compiles an RSP file"
|
5
|
|
#
|
6
|
|
# \description{
|
7
|
|
# @get "title".
|
8
|
|
# }
|
9
|
|
#
|
10
|
|
# @synopsis
|
11
|
|
#
|
12
|
|
# \arguments{
|
13
|
|
# \item{filename, path}{The filename and (optional) path of the
|
14
|
|
# RSP document to be compiled.}
|
15
|
|
# \item{...}{Additional arguments passed to @see "R.rsp::rfile".}
|
16
|
|
# \item{outPath}{The output and working directory.}
|
17
|
|
# \item{verbose}{See @see "R.utils::Verbose".}
|
18
|
|
# }
|
19
|
|
#
|
20
|
|
# \value{
|
21
|
|
# Returns the pathname of the generated document.
|
22
|
|
# }
|
23
|
|
#
|
24
|
|
# @author
|
25
|
|
#
|
26
|
|
# @keyword file
|
27
|
|
# @keyword IO
|
28
|
|
# @keyword internal
|
29
|
|
#*/###########################################################################
|
30
|
|
setMethodS3("compileRsp", "default", function(filename, path=NULL, ..., outPath=".", envir=parent.frame(), verbose=FALSE) {
|
31
|
|
|
32
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
33
|
|
# Validate arguments
|
34
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
35
|
|
# Arguments 'filename' & 'path':
|
36
|
1
|
pathname <- if (is.null(path)) filename else file.path(path, filename)
|
37
|
1
|
if (!isUrl(pathname)) {
|
38
|
1
|
pathname <- Arguments$getReadablePathname(pathname)
|
39
|
|
}
|
40
|
|
|
41
|
|
# Arguments 'outPath':
|
42
|
1
|
outPath <- Arguments$getWritablePath(outPath)
|
43
|
1
|
if (is.null(outPath)) outPath <- "."
|
44
|
|
|
45
|
|
# Argument 'verbose':
|
46
|
1
|
verbose <- Arguments$getVerbose(verbose)
|
47
|
1
|
if (verbose) {
|
48
|
1
|
pushState(verbose)
|
49
|
1
|
on.exit(popState(verbose))
|
50
|
|
}
|
51
|
|
|
52
|
1
|
verbose && enter(verbose, "Compiling RSP document")
|
53
|
|
|
54
|
|
# A local file?
|
55
|
1
|
if (!isUrl(pathname)) {
|
56
|
1
|
pathname <- getAbsolutePath(pathname)
|
57
|
1
|
verbose && cat(verbose, "RSP pathname (absolute): ", pathname)
|
58
|
1
|
verbose && printf(verbose, "Input file size: %g bytes\n", file.info(pathname)$size)
|
59
|
|
}
|
60
|
|
|
61
|
1
|
verbose && cat(verbose, "Output and working directory: ", outPath)
|
62
|
|
|
63
|
1
|
opwd <- "."
|
64
|
1
|
on.exit(setwd(opwd), add=TRUE)
|
65
|
1
|
if (!is.null(outPath)) {
|
66
|
1
|
opwd <- setwd(outPath)
|
67
|
|
}
|
68
|
|
|
69
|
1
|
pathname2 <- rfile(pathname, ..., envir=envir)
|
70
|
1
|
setwd(opwd); opwd <- "."
|
71
|
|
|
72
|
1
|
res <- pathname2
|
73
|
1
|
verbose && print(verbose, res)
|
74
|
|
|
75
|
1
|
verbose && exit(verbose)
|
76
|
|
|
77
|
1
|
res
|
78
|
|
}) # compileRsp()
|