Skip to content

Commit

Permalink
vectorize move_dir()
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Jul 19, 2016
1 parent c46f537 commit 5624e1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ render_book = function(
}
# move _files and _cache from _bookdown_files to ./, then from ./ to _bookdown_files
aux_dirs = files_cache_dirs(aux_diro)
move_dir(aux_dirs, basename(aux_dirs))
move_dirs(aux_dirs, basename(aux_dirs))
on.exit({
aux_dirs = files_cache_dirs('.')
if (length(aux_dirs)) {
dir_create(aux_diro)
move_dir(aux_dirs, file.path(aux_diro, basename(aux_dirs)))
move_dirs(aux_dirs, file.path(aux_diro, basename(aux_dirs)))
}
}, add = TRUE)

Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ move_dir = function(from, to) {
unlink(from, recursive = TRUE)
}

move_dirs = function(from, to) mapply(move_dir, from, to)

existing_files = function(x, first = FALSE) {
x = x[file.exists(x)]
if (first) head(x, 1) else x
Expand Down

0 comments on commit 5624e1d

Please sign in to comment.