Skip to content

Commit

Permalink
return unnormalized paths invisible
Browse files Browse the repository at this point in the history
  • Loading branch information
schochastics committed Sep 7, 2023
1 parent d6b514a commit 8f8ad08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions R/export_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ export_list <- function(x, file, archive = "", ...) {
if (is.na(archive_format$compress) && archive_format$file != "") {
outfiles <- file.path(archive_format$file, outfiles)
}
outfiles <- normalizePath(outfiles, mustWork = FALSE)
outfiles_normalized <- normalizePath(outfiles, mustWork = FALSE)

out <- list()
for (f in seq_along(x)) {
out[[f]] <- try(export(x[[f]], file = outfiles[f], ...), silent = TRUE)
out[[f]] <- try(export(x[[f]], file = outfiles_normalized[f], ...), silent = TRUE)
if (inherits(out[[f]], "try-error")) {
warning(sprintf("Export failed for element %d, filename: %s", f, outfiles[f]))
}
}
if (!is.na(archive_format$compress)) {
.create_directory_if_not_exists(archive)
compress_out(archive, outfiles)
unlink(outfiles)
compress_out(archive, outfiles_normalized)
unlink(outfiles_normalized)
return(invisible(archive))
}
return(invisible(outfiles))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_export_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test_that("export_list() works", {
expect_true(all.equal(mylist[["mtcars3"]], import("mtcars3.csv")))

names(mylist) <- NULL
expect_true(identical(export_list(mylist, file = "mtcars_%s.csv"), normalizePath(paste0("mtcars_", 1:3, ".csv"))))
expect_true(identical(export_list(mylist, file = "mtcars_%s.csv"), paste0("mtcars_", 1:3, ".csv")))

names(mylist) <- c("a", "", "c")
expect_error(export_list(mylist), label = "export_list() fails without 'file' argument")
Expand Down

0 comments on commit 8f8ad08

Please sign in to comment.