file_matches-methods: Generic function to test whether a file name conforms to the...

file_matchesR Documentation

Generic function to test whether a file name conforms to the given FileFormat instance. Will test for match to either header file or data file

Description

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 signature '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

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.

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

See Also

header_file_matches, data_file_matches for individual file type checking

Examples

## Not run: 
# 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

## End(Not run)


bbuchsbaum/neuroim2 documentation built on Jan. 2, 2025, 3:38 p.m.