| # File src/library/base/R/zdynvars.R |
| # Part of the R package, https://www.R-project.org |
| # |
| # Copyright (C) 1995-2014 The R Core Team |
| # |
| # This program is free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 2 of the License, or |
| # (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # A copy of the GNU General Public License is available at |
| # https://www.R-project.org/Licenses/ |
| |
| ## Need to ensure this comes late enough ... |
| ## Perhaps even merge it into the common profile? |
| |
| .dynLibs <- local({ |
| ## <NOTE> |
| ## Versions of R prior to 1.4.0 had .Dyn.libs in .AutoloadEnv |
| ## (and did not always ensure getting it from there). |
| ## Until 1.6.0, we consistently used the base environment. |
| ## Now we have a dynamic variable instead. |
| ## </NOTE> |
| .Dyn.libs <- structure(list(), class = "DLLInfoList") |
| function(new) { |
| if(!missing(new)) { |
| class(new) <- "DLLInfoList" |
| .Dyn.libs <<- new |
| } |
| else |
| .Dyn.libs |
| } |
| }) |
| |
| .libPaths <- local({ |
| .lib.loc <- character() # Profiles need to set this. |
| function(new) { |
| if(!missing(new)) { |
| ## paths don't really need to be unique, but searching |
| ## large library trees repeatedly would be inefficient. |
| ## Use normalizePath for display |
| new <- Sys.glob(path.expand(new)) |
| paths <- c(new, .Library.site, .Library) |
| paths <- paths[dir.exists(paths)] |
| .lib.loc <<- unique(normalizePath(paths, "/")) |
| } |
| else |
| .lib.loc |
| } |
| }) |