diff --git a/R/write_ods.R b/R/write_ods.R index 8ca9d55..6b52932 100644 --- a/R/write_ods.R +++ b/R/write_ods.R @@ -5,16 +5,15 @@ ## .FODS_FOOTER <- paste(readLines("benchmark/fods_footer.xml"), collapse = "\n") ## usethis::use_data(.CONTENT, .FOOTER, .FODS_HEADER, .FODS_FOOTER, internal = TRUE, overwrite = TRUE) -.zip_tmp_to_path <- function(temp_ods_dir, path, overwrite = TRUE, flat = FALSE) { +.zip_tmp_to_path <- function(temp_ods_dir, path, flat = FALSE) { if (flat) { return(path) ## do nothing } - wd <- getwd() - on.exit(setwd(wd), add = TRUE) - setwd(temp_ods_dir) - zip::zip(basename(path), include_directories = FALSE, recurse = TRUE, files = dir(), mode = "cherry-pick") - setwd(wd) - file.copy(file.path(temp_ods_dir, basename(path)), path, overwrite = overwrite) + temp_ods <- file.path(temp_ods_dir, basename(path)) + zip::zip(zipfile = temp_ods, include_directories = FALSE, recurse = TRUE, + files = list.files(temp_ods_dir), mode = "cherry-pick", + root = temp_ods_dir) + file.copy(temp_ods, path, overwrite = TRUE) return(path) }