R/helpers.R

Defines functions get_ext

get_ext <- function(file){
  # remove a path
  splitted    <- strsplit(x=fn, split=.Platform$file.sep)[[1]]
  # or use .Platform$file.sep in stead of '/'
  fn          <- splitted [length(splitted)]
  ext         <- ''
  splitted    <- strsplit(x=fn, split='\\.')[[1]]
  l           <-length (splitted)
  if (l > 1 && sum(splitted[1:(l-1)] != ''))  ext <-splitted [l]
  # the extention must be the suffix of a non-empty name
  ext
}
byu-transpolab/nemsr documentation built on Feb. 10, 2023, 11:24 p.m.