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
Source: R/all_generic.R
, R/file_format.R
file_matches-methods.Rd
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:
Checks if the file name matches either the header or data format
Verifies the existence of the corresponding paired file
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
} # }