Read a chunk of directory entries into a buffer.
Set ptr to start of the buffer.
Check the extension at ptr[8].
If extension matches, do a thing.
Set ptr to ptr + 32 and loop.
Note that this is for MS-DOS 2.0 which didn't handle "*.FOO" searches on the kernel side (the star expansion was done on the COMMAND.COM side via the MakeFcb [2] procedure). MS-DOS 3.0 introduced the star wildcard on the kernel side, so it might have taken advantage of that... but there isn't source code for MS-DOS 3.0.
[0] https://github.com/Microsoft/MS-DOS/tree/master/v2.0/source
[1] https://github.com/Microsoft/MS-DOS/blob/master/v2.0/source/...
[2] https://github.com/Microsoft/MS-DOS/blob/master/v2.0/source/...
Also note that DOS 2.0 incurred quite significant changes to fs code, as it was the first version to support directories. Before that, the namespace was flat.
MS-DOS 1.25 does pattern matching mostly the same way [0]. The code is a bit simpler as it doesn't have the crazy macro stuff that MS-DOS 2.0 code has, but if you look a bit around the files, you'll see that it is mostly the same code just moved around and split in several files. The file scan works again in almost the same way, reading each directory entry one by one and doing the pattern matching after the fact.
[0] https://github.com/Microsoft/MS-DOS/blob/master/v1.25/source...
Read "x" as *, because I could not for the life of me get the star work as a star within a word in this comment.
There was no space on a disk for metadata. You couldn't put metadata on a tape. There wasn't enough memory in the computer for the OS to determine a file type by reading a header, and even if there was, some operating systems had their DOS in ROM, so that would mean never adding any more file types (I'm looking at you, CBM PRG, USR, SEQ, REL files!).