checkFilePath: Check If File Is Available For Reading

View source: R/checkFilePath.R

checkFilePathR 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 = "",
  compressedOption = TRUE,
  strictExtension = FALSE,
  stopIfNothing = FALSE,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

fileName

(character) name of file to be tested; may also include an absolute or relative path

path

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

expectExt

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

compressedOption

(logical) also look for .gz compressed files

strictExtension

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

stopIfNothing

(logical) decide if function should give error or warning if no files found

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")

wrMisc documentation built on Nov. 17, 2023, 5:09 p.m.