Learn R Programming

ff (version 4.0.4)

delete: Deleting the file behind an ff object

Description

The generic delete deletes the content of an object without removing the object itself. The generic deleteIfOpen does the same, but only if is.open returns TRUE.

Usage

delete(x, …)
deleteIfOpen(x, …)
# S3 method for ff
delete(x, …)
# S3 method for ffdf
delete(x, …)
# S3 method for ff_pointer
delete(x, …)
# S3 method for default
delete(x, …)
# S3 method for ff
deleteIfOpen(x, …)
# S3 method for ff_pointer
deleteIfOpen(x, …)

Arguments

x

an ff or ram object

further arguments (not used)

Value

delete returns TRUE if the/all ff files could be removed and FALSE otherwise. deleteIfOpen returns TRUE if the/all ff files could be removed, FALSE if not and NA if the ff object was open.

Details

The proper sequence to fully delete an ff object is: delete(x);rm(x), where delete.ff frees the Memory Mapping resources and deletes the ff file, leaving intact the R-side object including its class, physical and virtual attributes. The default method is a compatibility function doing something similar with ram objects: by assiging an empty list to the name of the ram object to the parent frame we destroy the content of the object, leaving an empty stub that prevents raising an error if the parent frame calls the delete(x);rm(x) sequence. The deleteIfOpen does the same as delete but protects closed ff objects from deletion, it is mainly intended for use through a finalizer, as are the ff_pointer methods.

See Also

ff, close.ff, open.ff, reg.finalizer

Examples

Run this code
# NOT RUN {
  message('create the ff file outside getOption("fftempir"), 
    it will have default finalizer "close", so you need to delete it explicitely')
  x <- ff(1:12, pattern="./ffexample")
  delete(x)
  rm(x)
# }

Run the code above in your browser using DataLab