R Under development (unstable) (2024-06-28 r86850 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 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)) + status <- utils::zip(FILE.zip, this.path::basename2(FILE.R)) + on.exit() + setwd(owd) + if (status == 0L) { + 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/RtmpawOyRZ/file13c410b02ec0.R" Source: path of top level environment, copied from call to function 'sourcelike' [1] "D:/temp/RtmpawOyRZ/file13c410b02ec0.R" Source: path of srcfile, copied from call to function 'sourcelike' [1] "D:/temp/RtmpawOyRZ/file13c410b02ec0.R" Source: path of srcfile, copied from call to function 'sourcelike' [1] "D:/temp/RtmpawOyRZ/file13c410b02ec0.R" ofile: ../../../../../temp/RtmpawOyRZ/file13c410b02ec0.R file: D:/temp/RtmpawOyRZ/file13c410b02ec0.R lines: source: set.sys.path.was.here: NULL n: 11 adding: file13c410b02ec0.R (deflated 63%) > 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: ../../../../../temp/RtmpawOyRZ/file13c4618a7ad.zip:file13c410b02ec0.R associated.with.file: TRUE source: set.sys.path.was.here: NULL n: 29 > > proc.time() user system elapsed 0.17 0.03 0.25