file.resize: Change size of move an existing file

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Change size of an existing file (on some platforms sparse files are used) or move file to other name and/or location.

Usage

1
2
  file.resize(path, size)
  file.move(from, to)

Arguments

path

file path (on windows it uses a 'windows' backslash path!)

size

new filesize in bytes as double

from

old file path

to

new file path

Details

file.resize can enlarge or shrink the file. When enlarged, the file is filled up with zeros. Some platform implementations feature sparse files, so that this operation is very fast. We have tested:

The following work but do not support sparse files

file.move tries to file.rename, if this fails (e.g. across file systems) the file is copied to the new location and the old file is removed, see file.copy and file.remove.

Value

logical scalar repesenting the success of this operation

Author(s)

Daniel Adler

See Also

file.create, file.rename, file.info, file.copy, file.remove

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 x <- tempfile()
 newsize <- 23       # resize and size to 23 bytes.
 file.resize(x, newsize)
 file.info(x)$size == newsize
 ## Not run: 
   newsize <- 8*(2^30) # create new file and size to 8 GB.
   file.resize(x, newsize)
   file.info(x)$size == newsize
 
## End(Not run)
 y <- tempfile()
 file.move(x,y)
 file.remove(y)

OHDSI/ff documentation built on May 7, 2019, 8:30 p.m.