Skip to content

Commit

Permalink
Remove setwd() fix #165 [no ci] (#166)
Browse files Browse the repository at this point in the history
* Remove `setwd()` fix #165

* Make sure file overwrite
  • Loading branch information
chainsawriot authored Sep 4, 2023
1 parent a81f54a commit 6dfe4d0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions R/write_ods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 6dfe4d0

Please sign in to comment.