~showard314/ubuntu/karmic/r-base/remove_start_comments

« back to all changes in this revision

Viewing changes to src/library/base/R/load.R

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2009-01-19 12:40:24 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090119124024-abxsf4e0y7713w9m
Tags: 2.8.1-2
debian/control: Add another Build-Depends: exclusion for the 
'kfreebsd-i386 kfreebsd-amd64 hurd-i386' architecture to openjdk-6-jdk.
Thanks to Petr Salinger for the heads-up.               (Closes: 512324)

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
save <- function(..., list = character(0),
45
45
                 file = stop("'file' must be specified"),
46
46
                 ascii = FALSE, version = NULL, envir = parent.frame(),
47
 
                 compress = !ascii, eval.promises = TRUE)
 
47
                 compress = !ascii, eval.promises = TRUE, precheck = TRUE)
48
48
{
49
49
    opts <- getOption("save.defaults")
50
50
    if (missing(compress) && ! is.null(opts$compress))
61
61
        invisible(.Internal(save(list, file, ascii, version, envir,
62
62
                                 eval.promises)))
63
63
    else {
 
64
        if (precheck) {
 
65
            ## check for existence of objects before opening connection
 
66
            ## (and e.g. clobering file)
 
67
            ok <- unlist(lapply(list, exists, envir=envir))
 
68
            if(!all(ok)) {
 
69
                n <- sum(!ok)
 
70
                stop(sprintf(ngettext(n,
 
71
                                      "object %s not found",
 
72
                                      "objects %s not found"
 
73
                                      ),
 
74
                             paste(sQuote(list[!ok]), collapse = ", ")
 
75
                             ), domain = NA)
 
76
            }
 
77
        }
64
78
        if (is.character(file)) {
65
79
            if (file == "") stop("'file' must be non-empty string")
66
80
            if (compress) con <- gzfile(file, "wb")
78
92
}
79
93
 
80
94
save.image <- function (file = ".RData", version = NULL, ascii = FALSE,
81
 
                        compress = !ascii, safe = TRUE) {
 
95
                        compress = !ascii, safe = TRUE)
 
96
{
82
97
    if (! is.character(file) || file == "")
83
98
        stop("'file' must be non-empty string")
84
99
 
108
123
    on.exit(file.remove(outfile))
109
124
    save(list = ls(envir = .GlobalEnv, all.names = TRUE), file = outfile,
110
125
         version = version, ascii = ascii, compress = compress,
111
 
         envir = .GlobalEnv)
 
126
         envir = .GlobalEnv, precheck = FALSE)
112
127
    if (safe)
113
128
        if (! file.rename(outfile, file)) {
114
129
            on.exit()
117
132
    on.exit()
118
133
}
119
134
 
120
 
sys.load.image <- function(name, quiet) {
 
135
sys.load.image <- function(name, quiet)
 
136
{
121
137
    if (file.exists(name)) {
122
138
        load(name, envir = .GlobalEnv)
123
139
        if (! quiet)