NEWS | R Documentation |
this.path()
now accepts argument contents
that returns the contents of the executing script.
try.this.path()
now accepts argument contents
to get the contents of the executing script, NULL
if
that fails.
local.path()
is defunct and should be replaced with
this.path(local = TRUE)
.
Sys.path()
and Sys.dir()
are defunct and should be
replaced with this.path(verbose = FALSE)
and
this.dir(verbose = FALSE)
.
inside.source()
/ / set.this.path()
/ /
this.path(local = TRUE)
more rigorously check that they are
called from a valid context.
Fixed display issues in HTML docs when using ‘Run example’ button.
this.path()
no longer throws an error when multiple
-f FILE, --file=FILE
arguments are provided to a shell, and instead returns the last
FILE (ignoring -f -,
--file=-).
Added path.split()
, path.split.1()
, and
path.unsplit()
for splitting and unsplitting paths into
components.
this.path()
now works when run in ‘VSCode’ with the
‘radian’ console.
this.path()
now works in ‘Jupyter’. Added
set.this.path.jupyter()
for explicitly declaring the path of the
‘Jupyter’ notebook.
this.path()
now works inside compiler::loadcmp()
.
this.path()
now works inside box::use()
.
For logging purposes, this.path(for.msg = TRUE)
will now
return "Untitled"
when appropriate.
inside.source()
/ / set.this.path()
now accept
argument Function
specifying the name of the function
and package in which they are called.
this.path()
now accepts argument local
to
confine the search for the executing script to the local environment in
which inside.source()
/ / set.this.path()
was called.
Also added local.path()
, short for
this.path(local = TRUE)
.
Added unset.this.path()
to undo a call to
inside.source()
/ / set.this.path()
.
Added check.proj()
for checking that this.path()
and
this.proj()
are working correctly.
Added reset.this.proj()
to reset the paths saved by
this.proj()
.
Added try.this.path()
and try.shFILE()
to get the
normalized path of the executing script, the original path if that
fails, NA_character_
if that fails as well.
as.relative.path()
and as.rel.path()
are defunct and
should be replaced with rel2here()
.
shFILE(for.msg = TRUE, default = <...>)
now does not
evaluate default
, as intended. By extension,
this.path(for.msg = TRUE)
now returns
NA_character_
when running from a shell instead of
incorrectly throwing an error.
shFILE()
now parses the command line arguments in the exact
same manner as R itself, more accurately selecting
FILE.
A relative path returned by relpath()
/ /
as.rel.path()
will always start with "./"
or
"../"
.
Added set.this.path()
, an alias for inside.source()
.
Added Sys.putenv()
, an alternate method for setting
environment variables.
C code no longer uses lang1()
through lang6()
with
multiple unprotected arguments, uses allocList()
and
SETCAR()
instead.
C code no longer uses sprintf()
, uses snprintf()
instead.
this.path does a much better job of determining if the R session is running from ‘VSCode’.
this.path does a much better job of determining the path of the executing script from ‘Rgui’.
this.path()
now works inside knitr::knit()
. By
extension, withArgs(knitr::knit())
now also works.
this.path()
now accepts argument original
that returns the executing script's original (unnormalized) path.
this.path()
now accepts argument for.msg
that
returns a character string that can be used in diagnostic messages / /
warnings / / errors. It should be noted that
this.path(for.msg = TRUE)
should not be used for constructing
file paths.
shFILE()
also accepts argument original
that
returns the original FILE from the command line
arguments.
Added splitext()
, removeext()
, ext()
, and
ext<-()
for manipulating paths with extensions.
Added progArgs()
, similar to fileArgs()
but better,
might remove fileArgs()
later.
Added is.main()
for determining if an expression is run in a
top-level code environment.
Added wrap.source()
and inside.source()
for
implementing this.path()
with any source()
-like
function.
Added LINENO()
for determining the line number of the
executing expression in the executing script.
Added relpath()
, a version of as.rel.path()
with
different default argument values.
Added OS.type
, a list of TRUE
/ /
FALSE
values giving more details about the operating
system.
normalized.shFILE()
, this.path2()
,
this.dir2()
, and this.dir3()
are defunct and should be
replaced with shFILE()
, this.path(default = NULL)
,
this.dir(default = NULL)
, and
this.dir(default = getwd())
, respectively.
check.path()
and check.dir()
now use
path.join()
instead of file.path()
.
fileArgs()
, progArgs()
, from.shell()
, and
is.main()
no longer force the normalization of the executing
script's path, but instead save it as a promise to be evaluated later
if / / when desired.
this.path()
now works when called in a script from a shell
on Ubuntu installed on an Android (where
.Platform$GUI == "unknown"
, normally "unix"
).
Fixed path.join()
, basename2()
, and dirname2()
not having a trailing nul-character.
this.dir()
, here()
, and this.proj()
all use
path.join()
and dirname2()
instead of file.path()
and dirname()
, this may change behaviour for some users and
cases, but should be an improvement overall.
Added path.join()
, basename2()
, and dirname2()
for constructing and manipulating paths to files. These are based on
file.path()
, basename()
, and dirname()
, but behave
differently with network shares and a few important edge cases.
Added tryCatch2()
, introducing argument else.
similar to try except
in ‘Python’.
Added else.
argument to this.path()
,
this.dir()
, shFILE()
, and normalized.shFILE()
, a
function to act on the return value.
Added asArgs()
, fileArgs()
, and withArgs()
to
more easily provide arguments to a script.
Added from.shell()
to determine if a script was run from a
shell.
Added this.proj(...)
, similar to here::here(...)
,
except that this.proj()
supports multiple projects in one R
session and is independent of working directory.
this.path::here()
no longer uses dirname()
on a UNC
path.
this.path()
and others now work in ‘VSCode’.
when source()
-ing a file URL,
source("file:///path/to/file")
, this.path()
no longer
attempts to re-open a connection.
All previously defunct functions were removed entirely.
this.path()
, this.dir()
, shFILE()
, and
normalized.shFILE()
were given a new argument default
that will be evaluated and returned if there is no executing script or
command line argument FILE was not found.
this.path2()
, this.dir2()
, and this.dir3()
are
deprecated and should be replaced with
this.path(default = NULL)
, this.dir(default = NULL)
, and
this.dir(default = getwd())
, respectively.
normalized.shFILE()
no longer sets attribute
"this.path.from.shell"
, that is now handled by
this.path()
.