vsi_copy_file {gdalraster}R Documentation

Copy a source file to a target filename

Description

vsi_copy_file() is a wrapper for VSICopyFile() in the GDAL Common Portability Library. The GDAL VSI functions allow virtualization of disk I/O so that non file data sources can be made to appear as files. See https://gdal.org/user/virtual_file_systems.html. Requires GDAL >= 3.7.

Usage

vsi_copy_file(src_file, target_file, show_progress = FALSE)

Arguments

src_file

Character string. Filename of the source file.

target_file

Character string. Filename of the target file.

show_progress

Logical scalar. If TRUE, a progress bar will be displayed (the size of src_file will be retrieved in GDAL with VSIStatL()). Default is FALSE.

Details

The following copies are made fully on the target server, without local download from source and upload to target:

Value

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

Note

If target_file has the form /vsizip/foo.zip/bar, the default options described for the function addFilesInZip() will be in effect.

See Also

copyDatasetFiles(), vsi_stat(), vsi_sync()

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 <- tempfile(fileext = ".tif")

# Requires GDAL >= 3.7
if (as.integer(gdal_version()[2]) >= 3070000) {
  result <- vsi_copy_file(elev_file, tmp_file)
  print(result)

  vsi_unlink(tmp_file)
}

[Package gdalraster version 1.10.0 Index]