hasFileSuffix function

Checks if filepath ends in suffix (ignoring lower/upper case differences). If suffix does not start with a '.' it is prepended automatically.

Checks if filepath ends in suffix (ignoring lower/upper case differences). If suffix does not start with a '.' it is prepended automatically.

hasFileSuffix(filepath, suffix)

Arguments

  • filepath: A relative or absolute path to a file, whose suffix is checked
  • suffix: This is the suffix we expect (the '.' is prepended internally if missing)

Returns

TRUE if yes, FALSE otherwise

Examples

hasFileSuffix("bla.txt", "txt") # TRUE hasFileSuffix("bla.txt", ".txt") # TRUE hasFileSuffix("bla.txt", ".TXT") # TRUE hasFileSuffix("foo", "") # TRUE hasFileSuffix("", "") # TRUE hasFileSuffix("bla.txt", "doc") # FALSE hasFileSuffix("bla.txt", ".doc") # FALSE hasFileSuffix("fo", ".doc") # FALSE hasFileSuffix("", ".doc") # FALSE
  • Maintainer: Chris Bielow
  • License: MIT + file LICENSE
  • Last published: 2025-03-23