Skip to content

Commit

Permalink
Merge pull request #263 from jmbarbone/262-temp-files
Browse files Browse the repository at this point in the history
changes in temp directory related to #262
  • Loading branch information
JanMarvin authored Sep 30, 2021
2 parents fe7bd5b + 590e798 commit 02f524a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* `read.xlsx()` again accepts `.xlsm` files ([#205](https://github.com/ychps/openxlsx/issues/205),
[#209](https://github.com/ychps/openxlsx/issues/209))
* `makeHyperlinkString()` does no longer require a sheet argument ([#57](https://github.com/ychps/openxlsx/issues/57), [#58](https://github.com/ychps/openxlsx/issues/58))
* improvements in how `openxlsx` creates temporary directories (see [#262](https://github.com/ychps/openxlsx/issues/262))


# openxlsx 4.2.4
Expand Down
2 changes: 1 addition & 1 deletion R/loadWorkbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ loadWorkbook <- function(file, xlsxFile = NULL, isUnzipped = FALSE) {
}

## create temp dir
xmlDir <- file.path(tempdir(), paste0(tempfile(tmpdir = ""), "_openxlsx_loadWorkbook"))
xmlDir <- tempfile()

## Unzip files to temp directory
xmlFiles <- unzip(file, exdir = xmlDir)
Expand Down
6 changes: 3 additions & 3 deletions R/wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -2887,7 +2887,7 @@ getNamedRegions.default <- function(x) {
stop(sprintf("File '%s' does not exist.", x))
}

xmlDir <- file.path(tempdir(), "named_regions_tmp")
xmlDir <- tempfile()
xmlFiles <- unzip(x, exdir = xmlDir)

workbook <- grep("workbook.xml$", xmlFiles, perl = TRUE, value = TRUE)
Expand Down Expand Up @@ -3355,7 +3355,7 @@ getDateOrigin <- function(xlsxFile) {
}

## create temp dir and unzip
xmlDir <- file.path(tempdir(), "_excelXMLRead")
xmlDir <- tempfile()
xmlFiles <- unzip(xlsxFile, exdir = xmlDir)

on.exit(unlink(xmlDir, recursive = TRUE), add = TRUE)
Expand Down Expand Up @@ -3398,7 +3398,7 @@ getSheetNames <- function(file) {
}

## create temp dir and unzip
xmlDir <- file.path(tempdir(), "_excelXMLRead")
xmlDir <- tempfile()
xmlFiles <- unzip(file, exdir = xmlDir)

on.exit(unlink(xmlDir, recursive = TRUE), add = TRUE)
Expand Down

0 comments on commit 02f524a

Please sign in to comment.