file_check: strip illegal characters from filename, then check for...

View source: R/util_files.R

file_checkR Documentation

strip illegal characters from filename, then check for maximum path length

Description

If longer than N characters (Windows filesystem max path length), try with md5 hashed filename

Usage

file_check(file, strict = FALSE)

Arguments

file

filename to check (may include a path)

strict

boolean indicating 'strict mode' for checking the filename, if TRUE; only allow alphanumeric, underscore and '-'

Details

note; in contrast to using a timestamp or substring+index, this solution yields stable filenames. Should never fail if provided path/dir is reasonable

Examples

## Not run: 
  x = c("C:/temp/file*.txt", "test=2", "test=2.abc",
         paste0("c:/temp/",paste(rep("a",300),collapse=""),".txt"))
  cbind(x, file_check(x))

## End(Not run)
## Not run: 
  file_check("C:/temp/") # error, trailing slashes not allowed

## End(Not run)

ftwkoopmans/msdap documentation built on March 5, 2025, 12:15 a.m.