This file is indexed.

/usr/share/doc/r-cran-r.utils/tests/copyRenameFile.R is in r-cran-r.utils 2.6.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
library("R.utils")

# Create file
cat("Hello", file="hello.txt")
stopifnot(isFile("hello.txt"))

# Copy file
copyFile("hello.txt", "hello2.txt", verbose=TRUE)
stopifnot(isFile("hello2.txt"))

# Copy file
stopifnot(all(isFile(c("hello.txt", "hello2.txt"))))

# Copy file by overwriting existing file
copyFile("hello.txt", "hello2.txt", overwrite=TRUE)
stopifnot(isFile("hello2.txt"))

# Copy file to directory
pathD <- tempdir()
copyFile("hello.txt", pathD)
pathnameD <- file.path(pathD, "hello.txt")
stopifnot(isFile(pathnameD))
file.remove(pathnameD)

# Rename file
renameFile("hello2.txt", "hello3.txt", verbose=TRUE)
stopifnot(!isFile("hello2.txt"))
stopifnot(isFile("hello3.txt"))

# Rename file by overwriting existing file
renameFile("hello3.txt", "hello.txt", overwrite=TRUE)
stopifnot(!isFile("hello3.txt"))
stopifnot(isFile("hello.txt"))


# Move file to directory (and back)
# NOTE: We are not moving file to tempdir() just in case
# that is on a different file system which in case we
# risk getting error "cannot rename file reason 'Invalid
# cross-device link' (some Unix problem)
pathD <- "foo"
mkdirs(pathD)
renameFile("hello.txt", pathD)
pathnameD <- file.path(pathD, "hello.txt")
stopifnot(isFile(pathnameD))
renameFile(pathnameD, ".")


## Exception handling
res <- try(copyFile("hello.txt", "hello.txt"), silent=TRUE)
stopifnot(inherits(res, "try-error"))


# Cleanup
removeDirectory("foo")
file.remove("hello.txt")