I hope the reader will have the basic knowledge about the EXFAT filesystem. For finding a file from the SD card formatted with EXFAT filesystem, we need to read the file entries.
Basically there are 3 or more file entries associated with a single file. These file entries are File directory entry, Stream Extension directory entry and Filename Directory entry. Filename directory entry contains the filename and a single file can have more than one filename entry depending on the length of the filename but only can have one file and stream entry. Here I am not going into the detailed explanation of the file entries. But briefly I can say these file entries hold all the details about a file including starting cluster, file attributes, timestamp etc.
Lets assume we have to find a file called "myfile" which exists in directory "mydir/myfile" and the "mydir" contains different other files. Our PWD is "mydir" and we are staring a file search then file entry read will starts from the first cluster of "mydir". Initial process is to read the file directory entry located at the starting cluster of the "mydir". From the file directory entry we will get the secondary count value. The secondary count denotes the number of secondary directory entries(stream and filename entry) following the primary directory entry(File directory entry).
Next step is to read the stream extension directory entry and filename directory entry from the media. After reading these entries, from the filename directory entry we will extract the filename. As you know that EXFAT filesystem is case insensitive, we need to convert the filename to upcase and then compares with the required filename(already up-cased). If both filename matches we have successfully found the file we are looing for, otherwise again repeat the previous steps - reading the directory entries and comparing the filename. There are several other internal process involved during the search but in this post I am trying to give a high level point of view of the search process.