-
Notifications
You must be signed in to change notification settings - Fork 1
/
_after.R
39 lines (37 loc) · 895 Bytes
/
_after.R
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
# copy if inexistent or changed
copy.file = function(file,dest=NULL){
if(is.null(dest)){
dest=paste0("docs/",file)
}
if(
file.exists(file) && (
!file.exists(paste0("docs/",file)) ||
file.info(file)$mtime >=
file.info(paste0("docs/",file))$mtime
)
) file.copy(file,dest,overwrite=T)
}
# list of extra files/dirs to copy
copy.list = c(
"demo.html",
"data/",
"data_list.txt",
"icons/",
"ggplot_theme_options.R",
"joins.svg"
)
# iterate over copy list
for(path in copy.list){
# check if item is file or directory
if(dir.exists(path)){
# if directory doesn't exist, create it
if(!dir.exists(paste0("docs/",path))){
dir.create(paste0("docs/",path))
}
for(file in list.files(path)){
copy.file(paste0(path,file))
}
} else if(file.exists(path)){
copy.file(path)
} else warning("Path wrong in copy list!")
}