R Under development (unstable) (2023-09-11 r85126 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > local({ + + + FILE.R <- tempfile(fileext = ".R") + on.exit(unlink(FILE.R)) + writeLines("test.this.path <- function () + { + try(print({ this.path::sys.path(verbose = TRUE) })) + try(print({ this.path::env.path(verbose = TRUE) })) + try(print({ this.path::src.path(verbose = TRUE) })) + try(print({ this.path::this.path(verbose = TRUE) })) + } + + + test.this.path()", FILE.R) + + + sourcelike <- function(file) { + ofile <- file + file <- this.path::set.sys.path(file, Function = "sourcelike") + lines <- readLines(file, warn = FALSE) + filename <- this.path::sys.path(local = TRUE, for.msg = TRUE) + isFile <- !is.na(filename) + if (isFile) { + timestamp <- file.info(filename)$mtime[1] + if (is.na(timestamp)) + timestamp <- Sys.time() + } + else { + filename <- if (is.character(ofile)) ofile else "" + timestamp <- Sys.time() + } + srcfile <- srcfilecopy(filename, lines, timestamp, isFile) + this.path::set.src.path(srcfile) + envir <- new.env(hash = TRUE, parent = .BaseNamespaceEnv) + envir$.packageName <- filename + oopt <- options(topLevelEnvironment = envir) + on.exit(options(oopt)) + this.path::set.env.path(envir) + exprs <- parse(text = lines, srcfile = srcfile) + this.path::source.exprs(exprs, evaluated = TRUE, envir) + `.this.path::document.context` + } + + + this.path::source.exprs({ + + + x <- sourcelike(this.path::relpath(FILE.R)) + print(x, quote = FALSE) + + + y <- local({ + FILE.zip <- tempfile(fileext = ".zip") + on.exit(unlink(FILE.zip)) + local({ + owd <- getwd() + on.exit(setwd(owd)) + setwd(this.path::dirname2(FILE.R)) + if (!utils::zip(FILE.zip, this.path::basename2(FILE.R))) { + local({ + conn <- unz(this.path::relpath(FILE.zip), this.path::basename2(FILE.R)) + on.exit(close(conn)) + sourcelike(conn) + }) + } + }) + }) + print(y, quote = FALSE) + + + }) + + + }) > test.this.path <- function () + { + try(print({ this.path::sys.path(verbose = TRUE) })) + try(print({ this.path::env.path(verbose = TRUE) })) + try(print({ this.path::src.path(verbose = TRUE) })) + try(print({ this.path::this.path(verbose = TRUE) })) + } > > > test.this.path() Source: call to function 'sourcelike' [1] "D:/temp/Rtmpk5lYBe/file246645e9a72e8.R" Source: path of top level environment, copied from call to function 'sourcelike' [1] "D:/temp/Rtmpk5lYBe/file246645e9a72e8.R" Source: path of srcfile, copied from call to function 'sourcelike' [1] "D:/temp/Rtmpk5lYBe/file246645e9a72e8.R" Source: path of srcfile, copied from call to function 'sourcelike' [1] "D:/temp/Rtmpk5lYBe/file246645e9a72e8.R" ofile: ../../../../../temp/Rtmpk5lYBe/file246645e9a72e8.R file: D:/temp/Rtmpk5lYBe/file246645e9a72e8.R source: set.sys.path.was.here: NULL n: 11 adding: file246645e9a72e8.R (deflated 64%) > test.this.path <- function () + { + try(print({ this.path::sys.path(verbose = TRUE) })) + try(print({ this.path::env.path(verbose = TRUE) })) + try(print({ this.path::src.path(verbose = TRUE) })) + try(print({ this.path::this.path(verbose = TRUE) })) + } > > > test.this.path() Error in this.path::sys.path(verbose = TRUE) : 'this.path' cannot be used within a zip file Error in this.path::env.path(verbose = TRUE) : 'this.path' cannot be used within a zip file Error in this.path::src.path(verbose = TRUE) : 'this.path' cannot be used within a zip file Error in this.path::this.path(verbose = TRUE) : 'this.path' cannot be used within a zip file errcnd: for.msg: ./file246644d225776.zip:file246645e9a72e8.R associated.with.file: TRUE source: set.sys.path.was.here: NULL n: 29 > > proc.time() user system elapsed 0.15 0.06 0.26