Skip to content

Commit

Permalink
Fix #157 again (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
chainsawriot authored Aug 25, 2023
1 parent 465fea5 commit f8fc657
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ write_ods(list("some_car_data" = mtcars, "some_flower_data" = iris))

## bug fixes

* Fix #157 `list_fods_sheets()` cannot accept `~` as path
* Fix #157 `list_fods_sheets()` and `read_fods()` cannot accept `~` as path

# readODS 2.05

Expand Down
3 changes: 2 additions & 1 deletion R/read_ods.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
strings_as_factors,
verbose,
as_tibble)
path <- normalizePath(path)
if (flat) {
.get_sheet_names_func <- get_flat_sheet_names_
.read_ods_func <- read_flat_ods_
Expand Down Expand Up @@ -317,7 +318,7 @@ read_fods <- function(path,
as_tibble = TRUE,
.name_repair = "unique") {
## Should use match.call but there's a weird bug if one of the variable names is 'file'
.read_ods(path = path,
.read_ods(path = normalizePath(path, mustWork = FALSE),
sheet = sheet,
col_names = col_names,
col_types = col_types,
Expand Down
10 changes: 9 additions & 1 deletion tests/testthat/test_read_fods.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ test_that("Error when not correct", {
test_that("Return blank/error if mangled FODS", {
expect_warning(read_fods("../testdata/norows.fods"))
expect_warning(read_fods("../testdata/nocells.fods"))
})
})

test_that("fix #157", {
skip_if(file.access("~/", 2) != 0)
file.copy("../testdata/flat.fods", "~/flat_you_must_not_use_this_path.fods")
expect_error(read_fods("~/flat_you_must_not_use_this_path.fods"), NA)
expect_error(read_fods("~/flat_you_must_not_use_this_path_not.fods"))
on.exit(unlink("~/flat_you_must_not_use_this_path.fods"))
})

0 comments on commit f8fc657

Please sign in to comment.