safeFileOpen: A function that checks to see if a connection can be made to...

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/safeFileOpen.R

Description

This function checks to see if a given file name exists. If so, the function returns a connection to the file. Otherwise, it returns "fileName doest exist".

Usage

1
safeFileOpen(fileName)

Arguments

fileName

fileName a character string for the name of a file to which a connection is to be oppened

Details

When this function is used, users have to make sure to check to see if the returnd object inherits object "connection". Otherwise, the file doest not exist or a connection has not be made.

Value

The function returns a connection object that inherits class "connection" if the file exists and is opend. Otherwise, the string "fileName doest not exist"

Note

This function is no placed here to be used by various widgets. May be mored to a more suitable place later

Author(s)

Jianhua Zhang

See Also

file

Examples

1
2
3
4
5
6
write("A test file", "testFile4safeFileOpen")
tt <- safeFileOpen("testFile4safeFileOpen")
inherits(tt, "connection")
unlink("testFile4safeFileOpen")
tt <- safeFileOpen("testFile4safeFileOpen")
inherits(tt, "connection")

widgetTools documentation built on Nov. 8, 2020, 8:29 p.m.