Commit 188e4d94 authored by Radford Neal's avatar Radford Neal

start pruning old save/load code

parent da935947
Get rid of old save/load code for obsolete formats, since it would
need to be modified when env hash scheme is changed.
# File src/library/base/R/load.R # File src/library/base/R/load.R
# Part of the R package, http://www.R-project.org # Part of the R package, http://www.R-project.org
# Modifications for pqR Copyright (c) 2017 Radford M. Neal.
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
...@@ -17,7 +18,6 @@ ...@@ -17,7 +18,6 @@
load <- function (file, envir = parent.frame()) load <- function (file, envir = parent.frame())
{ {
if (is.character(file)) { if (is.character(file)) {
## files are allowed to be of an earlier format
## gzfile can open gzip, bzip2, xz and uncompressed files. ## gzfile can open gzip, bzip2, xz and uncompressed files.
con <- gzfile(file) con <- gzfile(file)
on.exit(close(con)) on.exit(close(con))
...@@ -29,12 +29,7 @@ load <- function (file, envir = parent.frame()) ...@@ -29,12 +29,7 @@ load <- function (file, envir = parent.frame())
## a check while we still know the call to load() ## a check while we still know the call to load()
if(grepl("RD[ABX][12]\r", magic)) if(grepl("RD[ABX][12]\r", magic))
stop("input has been corrupted, with LF replaced by CR") stop("input has been corrupted, with LF replaced by CR")
## Not a version 2 magic number, so try the pre-R-1.4.0 code error("Use of save versions prior to 2 is no longer allowed")
warning(gettextf("file %s has magic number '%s'\n Use of save versions prior to 2 is deprecated",
sQuote(basename(file)),
gsub("[\n\r]*", "", magic)),
domain = NA, call. = FALSE)
return(.Internal(load(file, envir)))
} }
} else if (inherits(file, "connection")) { } else if (inherits(file, "connection")) {
con <- if(inherits(file, "gzfile") || inherits(file, "gzcon")) file con <- if(inherits(file, "gzfile") || inherits(file, "gzcon")) file
...@@ -57,15 +52,15 @@ save <- function(..., list = character(), ...@@ -57,15 +52,15 @@ save <- function(..., list = character(),
ascii <- opts$ascii ascii <- opts$ascii
if (missing(version)) version <- opts$version if (missing(version)) version <- opts$version
if (!is.null(version) && version < 2) if (!is.null(version) && version < 2)
warning("Use of save versions prior to 2 is deprecated") error("Use of save versions prior to 2 is no longer allowed")
if(missing(list) && !length(list(...))) if(missing(list) && !length(list(...)))
warning("nothing specified to be save()d") warning("nothing specified to be save()d")
names <- as.character( substitute(list(...)))[-1L] names <- as.character( substitute(list(...)))[-1L]
list <- c(list, names) list <- c(list, names)
if (!is.null(version) && version == 1) if (!is.null(version) && version == 1) {
invisible(.Internal(save(list, file, ascii, version, envir, # Should no longer happen.
eval.promises))) }
else { else {
if (precheck) { if (precheck) {
## check for existence of objects before opening connection ## check for existence of objects before opening connection
......
...@@ -39,16 +39,14 @@ save.image(file = ".RData", version = NULL, ascii = FALSE, ...@@ -39,16 +39,14 @@ save.image(file = ".RData", version = NULL, ascii = FALSE,
written. The default value of \code{ascii} is \code{FALSE} which written. The default value of \code{ascii} is \code{FALSE} which
leads to a binary file being written.} leads to a binary file being written.}
\item{version}{the workspace format version to use. \code{NULL} \item{version}{the workspace format version to use. \code{NULL}
specifies the current default format. The version used from \R specifies the current default format. This is currently version 2,
0.99.0 to \R 1.3.1 was version 1. The default format as from \R and this is currently the only one allowed.}
1.4.0 is version 2.}
\item{envir}{environment to search for objects to be saved.} \item{envir}{environment to search for objects to be saved.}
\item{compress}{logical or character string specifying whether saving \item{compress}{logical or character string specifying whether saving
to a named file is to use compression. \code{TRUE} corresponds to to a named file is to use compression. \code{TRUE} corresponds to
\command{gzip} compression, and (from \R 2.10.0) character strings \command{gzip} compression, and (from \R 2.10.0) character strings
\code{"gzip"}, \code{"bzip2"} or \code{"xz"} specify the \code{"gzip"}, \code{"bzip2"} or \code{"xz"} specify the
type of compression. Ignored when \code{file} is a connection type of compression. Ignored when \code{file} is a connection.}
and for workspace format version 1.}
\item{compression_level}{integer: the level of compression to be \item{compression_level}{integer: the level of compression to be
used. Defaults to \code{6} for \command{gzip} compression and to used. Defaults to \code{6} for \command{gzip} compression and to
\code{9} for \command{bzip2} or \command{xz} compression.} \code{9} for \command{bzip2} or \command{xz} compression.}
...@@ -56,7 +54,7 @@ save.image(file = ".RData", version = NULL, ascii = FALSE, ...@@ -56,7 +54,7 @@ save.image(file = ".RData", version = NULL, ascii = FALSE,
forced before saving?} forced before saving?}
\item{precheck}{logical: should the existence of the objects be \item{precheck}{logical: should the existence of the objects be
checked before starting to save (and in particular before opening checked before starting to save (and in particular before opening
the file/connection)? Does not apply to version 1 saves.} the file/connection)?}
\item{safe}{logical. If \code{TRUE}, a temporary file is used for \item{safe}{logical. If \code{TRUE}, a temporary file is used for
creating the saved workspace. The temporary file is renamed to creating the saved workspace. The temporary file is renamed to
\code{file} if the save succeeds. This preserves an existing \code{file} if the save succeeds. This preserves an existing
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment