file.copy
File and Directory Manipulation

Description

These functions provide file and directory manipulation from within TIBCO Enterprise Runtime for R. They can check for file existence; they can create, copy, rename, or remove files; and they can append to files and create directories.

Usage

file.create(..., showWarnings = TRUE)
file.exists(...)
file.remove(...)
file.rename(from, to)
file.append(file1, file2)
file.copy(from, to, overwrite = recursive, recursive = FALSE)
file.symlink(from, to)
file.link(from, to)
dir.create(path, showWarnings = TRUE, recursive = FALSE, mode = "0777")
dir.exists(paths)

Arguments

..., from, to, file1, file2 character vectors containing file names. The ... arguments are concatenated to form one vector of character values.
showWarnings a logical value; if TRUE (the default), warnings on file or directory creation are displayed.
overwrite a logical value; if TRUE, the destination file(s) are overwritten if they exist. By default, FALSE.
recursive a logical value; if TRUE all elements in path are created if they do not already exist. By default, FALSE.
path a character vector giving a single path name.
paths a character vector giving any number of path names.
mode a character vector. Sets the access limits on a directory or file.

Details

file.create creates files with the specified names. If the file already exists, it is truncated to length zero.
file.exists returns a logical vector the length of the combined arguments that is TRUE for each file that exists. For any file that does not exist, FALSE. This function can be applied to a folder.
dir.exists(paths) returns a logical vector the length of its paths argument. This vector contains TRUE for each path that exists and is a directory (folder). Otherwise, it contains FALSE.
file.remove removes the specified files.
file.rename renames the single file given for from to the name given for to. This function can be applied on a folder.
file.append appends the contents of the files given for file2 to the files given for file1.
file.copy copies the files given for from to the names given for to. The to argument can specify a single existing directory.
file.symlink creates symbolic links on Unix-like platforms, which are not supported on the Windows platform. The specified to can be a file name or an existing directory.
file.link creates links on Unix-like platforms or hard links on Windows NTFS platform.
dir.create creates the single directory, unless recursive is TRUE, in which case all necessary directories specified for path are created. If the specified path exists, and showWarnings is TRUE, a warning message is displayed.
Value
returns a logical vector the length of the combined arguments. TRUE indicates a successful operation for that element.
Side Effects
Files or directories are created, removed, copied, or appended to.
See Also
file.access, file.show, basename, unlink.
Examples
tfile1 <- tempfile("a")
tfile2 <- tempfile("b")
tfile3 <- tempfile("c")
cat("This is file 1\n", file=tfile1)
cat("This is file 2\n", file=tfile2)
file.append(tfile1, tfile2)
file.copy(tfile1, tfile3)
file.remove(tfile1)
file.exists(tfile1)
tdir <- tempfile("d")
dir.create(tdir)
file.copy(c(tfile2, tfile3), tdir)
list.files(tdir)
# Clean up:
unlink(c(tfile1, tfile2, tfile3, tdir))

Package base version 4.0.0-28
Package Index