checkFilePath {wrMisc}R Documentation

Check If File Is Available For Reading

Description

This function allows tesing if a given file-name corresponds to an existing file (eg for reading lateron). Indications to the path and file-extensions may be given separately. If no files do match .gz compressed versions may be searced, too.

Usage

checkFilePath(
  fileName,
  path,
  expectExt = "",
  mode = "byFile",
  compressedOption = NULL,
  strictExtension = NULL,
  stopIfNothing = NULL,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

fileName

(character) name of file to be tested; may also include an absolute or relative path; if NULL and path as well as expectExt will take 1st file in given path and proper extension

path

(character, length=1) optional separate entry for path of fileName

expectExt

(character) file extension (will not be considered if "")

mode

(character) further details if function should give error or warning if no files found integrates previous argument compressedOption to also look for look for .gz compressed files; strictExtension to decide if extension (expectExt) - if given - should be considered obligatory; stopIfNothing to stop with error if no files found

compressedOption

deprected (logical) also look for .gz compressed files

strictExtension

deprected (logical) decide if extesion (expectExt) - if given - should be considered obligatory

stopIfNothing

deprected, please use argument mode instead !

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

Details

When the filename given by the user exists but it's file-extension is not matching expectExt the argument strictExtension allows to decide if the filename will still be returned or not.

When expectExt is given, initial search will look for perfect matches. However, if nothing is found and strictExtension=FALSE, a more relaxed and non-case-sensitive search will be performed.

Value

This function returns a character vector with verified path and file-name(s), returns NULL if nothing

See Also

file.exists

Examples

(RhomeFi <- list.files(R.home()))
file.exists(file.path(R.home(), "bin"))
checkFilePath(c("xxx","unins000"), R.home(), expectExt="dat")

[Package wrMisc version 1.15.0.3 Index]