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
# Part of the R package,
# Modifications for pqR Copyright (c) 2017 Radford M. Neal.
# 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
......@@ -17,7 +18,6 @@
load <- function (file, envir = parent.frame())
if (is.character(file)) {
## files are allowed to be of an earlier format
## gzfile can open gzip, bzip2, xz and uncompressed files.
con <- gzfile(file)
......@@ -29,12 +29,7 @@ load <- function (file, envir = parent.frame())
## a check while we still know the call to load()
if(grepl("RD[ABX][12]\r", magic))
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
warning(gettextf("file %s has magic number '%s'\n Use of save versions prior to 2 is deprecated",
gsub("[\n\r]*", "", magic)),
domain = NA, call. = FALSE)
return(.Internal(load(file, envir)))
error("Use of save versions prior to 2 is no longer allowed")
} else if (inherits(file, "connection")) {
con <- if(inherits(file, "gzfile") || inherits(file, "gzcon")) file
......@@ -57,15 +52,15 @@ save <- function(..., list = character(),
ascii <- opts$ascii
if (missing(version)) version <- opts$version
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(...)))
warning("nothing specified to be save()d")
names <- as.character( substitute(list(...)))[-1L]
list <- c(list, names)
if (!is.null(version) && version == 1)
invisible(.Internal(save(list, file, ascii, version, envir,
if (!is.null(version) && version == 1) {
# Should no longer happen.
else {
if (precheck) {
## check for existence of objects before opening connection
......@@ -39,16 +39,14 @@ save.image(file = ".RData", version = NULL, ascii = FALSE,
written. The default value of \code{ascii} is \code{FALSE} which
leads to a binary file being written.}
\item{version}{the workspace format version to use. \code{NULL}
specifies the current default format. The version used from \R
0.99.0 to \R 1.3.1 was version 1. The default format as from \R
1.4.0 is version 2.}
specifies the current default format. This is currently version 2,
and this is currently the only one allowed.}
\item{envir}{environment to search for objects to be saved.}
\item{compress}{logical or character string specifying whether saving
to a named file is to use compression. \code{TRUE} corresponds to
\command{gzip} compression, and (from \R 2.10.0) character strings
\code{"gzip"}, \code{"bzip2"} or \code{"xz"} specify the
type of compression. Ignored when \code{file} is a connection
and for workspace format version 1.}
type of compression. Ignored when \code{file} is a connection.}
\item{compression_level}{integer: the level of compression to be
used. Defaults to \code{6} for \command{gzip} compression and to
\code{9} for \command{bzip2} or \command{xz} compression.}
......@@ -56,7 +54,7 @@ save.image(file = ".RData", version = NULL, ascii = FALSE,
forced before saving?}
\item{precheck}{logical: should the existence of the objects be
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
creating the saved workspace. The temporary file is renamed to
\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