copyDir: Copy a directory using Robocopy on Windows and rsync on linux

Description Usage Arguments Author(s) Examples

Description

This will copy an entire directory using the faster copy options in Windows and Linux. The function will default to file.copy (which is slow). For lazyR databases, this can be useful for copying everything to a new computer, a network location etc.

Usage

1
2
3
copyDir(fromDir = NULL, toDir = NULL, useRobocopy = TRUE,
  overwrite = TRUE, delDestination = FALSE, create = TRUE,
  silent = FALSE)

Arguments

fromDir

The source lazyDir

toDir

The new lazyDir

useRobocopy

For Windows, this will use a system call to Robocopy which appears to be much faster than the internal file.copy function. Uses /MIR flag.

overwrite

Passed to file.copy

delDestination

Logical, whether the destination should have any files deleted, if they don't exist in the source. This is /purge

create

Passed to checkLazyDir

silent

Should a progress be printed

Author(s)

Eliot McIntire

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Not run: 
library(raster)
library(rgdal)
# make some objects
obj1 <- 1:10
obj2 <- 11:20
r <- raster::raster(matrix(1:9, ncol=3))
raster::writeRaster(r, file.path(tempdir(),"r.tif"), overwrite=TRUE)
raster::writeRaster(r, file.path(tempdir(),"ras.tif"), overwrite=TRUE)
rm(r, ras)
r <- raster::raster(file.path(tempdir(),"r.tif"))
ras <- raster::raster(file.path(tempdir(),"ras.tif"))

# identify a new and old lazyLoad db
fromDir <- file.path(tempdir(), "old")
toDir <- file.path(tempdir(), "new")
lazySave(obj1, r, ras, obj2, lazyDir=fromDir, overwrite=TRUE)

# copy to new lazyDir location
copyDir(fromDir, toDir, create=TRUE)

# remove the objects in memory and the old lazyLoad db
rm(obj1, obj2, r, ras)
unlink(fromDir, recursive=TRUE)

lazyLoad2(lazyDir=toDir) # Objects should be visible after this
ls()
unlink(toDir, recursive=TRUE)

## End(Not run)

PredictiveEcology/lazyR documentation built on May 8, 2019, 3:10 p.m.