Skip to content

Commit

Permalink
add file_show
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Sep 1, 2023
1 parent 3208005 commit faf368a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export(file_cp)
export(file_ext)
export(file_mv)
export(file_name)
export(file_show)
export(file_size)
export(fliplr)
export(flipud)
Expand Down
9 changes: 9 additions & 0 deletions R/cmd_func.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ file_cp <- function(files, outdir) {
file.copy(files, files_new)
}

#' @export
file_show <- function(f, ...) {
if (is_win()) {
shell.exec(f)
} else {
file.show(f, ...)
}
}

#' @rdname mkdir
#' @export
check_dir <- mkdir
Expand Down
2 changes: 1 addition & 1 deletion R/write_fig.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ showfig <- function(file, use.file_show = FALSE) {
is_wsl_rserver = dir.exists("/mnt/c") &&
file.exists("/usr/sbin/rstudio-server") && file_ext == "pdf"
if (file_ext %in% c("svg", "emf", "jpg", "png") || (is_wsl_rserver && use.file_show)) {
file.show(file)
file_show(file)
} else {
pdf_view(file)
}
Expand Down
2 changes: 1 addition & 1 deletion R/write_list2xlsx.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ write_list2xlsx <- function(x, file, .progress = "none", rowNames = FALSE, show
tmp <- llply(seq_along(x), writeIn, .progress = .progress)
if (.progress != "none") cat(sprintf("[---- Writing into xlsx file: %s ----]\n", file))
saveWorkbook(wb, file, overwrite = TRUE)
if (show) file.show(file)
if (show) file_show(file)
}

#' read_xlsx2list
Expand Down

0 comments on commit faf368a

Please sign in to comment.