Skip to contents

vsi_unlink() deletes a file object from the file system. This function goes through the GDAL VSIFileHandler virtualization and may work on unusual filesystems such as in memory. It is a wrapper for VSIUnlink() in the GDAL Common Portability Library. Analog of the POSIX unlink() function.

Usage

vsi_unlink(filename)

Arguments

filename

Character string. The path of the file to be deleted.

Value

Invisibly, 0 on success or -1 on an error.

Examples

# for illustration only
# this would normally be used with GDAL virtual file systems
elev_file <- system.file("extdata/storml_elev.tif", package="gdalraster")
tmp_file <- paste0(tempdir(), "/", "tmp.tif")
file.copy(elev_file,  tmp_file)
#> [1] TRUE
result <- vsi_unlink(tmp_file)
print(result)
#> [1] 0