openFile: open file in default application

View source: R/openFile.R

openFileR Documentation

open file in default application

Description

open a file using system2 with command based on operating system. Tries to open the file with the program associated with its file extension.
See openPDF to open files with sumatraPDF.

Usage

openFile(file, ...)

Arguments

file

Filename to be opened, as character string.

...

Further arguments passed to system2

Value

Result of try(system2, ...), invisibly

Author(s)

Berry Boessenkool, berry-b@gmx.de, Aug 2017

References

https://askubuntu.com/questions/15354, https://apple.stackexchange.com/questions/212583

See Also

openPDF, system2, checkFile

Examples

## Not run:  # excluded from CRAN checks, file opening not wanted
openFile("README.md")
openFile("Tests.R")
openFile(c("README.md","Tests.R"))
is.error(openFile("dummydummydoesntexist.R"), TRUE, TRUE)
openFile(tempdir())

## End(Not run)
#' # To open folders (not files) with system2:
# "nautilus" on linux ubuntu
# "open" or "dolphin" on mac
# "explorer" or "start" on windows
# But open / xdg-open seems to work as well


berryFunctions documentation built on May 29, 2024, 4:01 a.m.