Skip to contents

Validates whether a file name conforms to the specified FileFormat and verifies the existence of both header and data files.

Usage

file_matches(x, file_name)

# S4 method for class 'FileFormat,character'
file_matches(x, file_name)

Arguments

x

A FileFormat object specifying the format requirements

file_name

A character string specifying the file name to validate

Value

TRUE for match, FALSE otherwise

A logical value: TRUE if the file matches the format and both header and data files exist, FALSE otherwise

Details

The function performs the following validation steps:

  1. Checks if the file name matches either the header or data format

  2. Verifies the existence of the corresponding paired file

  3. Returns FALSE if either check fails

File names are validated using case-sensitive extension matching.

See also

header_file_matches, data_file_matches for individual file type checking

Examples

if (FALSE) { # \dontrun{
# Create a FileFormat for ANALYZE format
fmt <- new("FileFormat", header_extension = "hdr", data_extension = "img")

# Check if files exist and match format
file_matches(fmt, "brain_scan.hdr")  # TRUE if both .hdr and .img exist
file_matches(fmt, "brain_scan.nii")  # FALSE for wrong extension
} # }