static File findInDir(File dir, String name, Comparator<String> nameComp) throws IOException {
		File exact = new File(dir, name);
		if (exact.exists()) {
			// Skip listing entire dir contents if exact match exists and the match agrees with
			// the caller's comparator.  The comparator could reject this test, for example
			// if it was an exact case compare and the requested filename's case didn't match
			// the actual file's case (on windows).
			exact = updateCaseInsensitiveFilePath(exact);
			if (nameComp.compare(exact.getName(), name) == 0) {
				return exact;
			}
		}

		// Searches for "name" in the list of files found in the directory.
		// Because a case-insensitive comparator could match on several files in the same directory,
		// query for all the files before picking a match: either an exact string match, or
		// if there are several candidates, the first in the list after sorting.
		File[] files = dir.listFiles();
		List<File> candidateMatches = new ArrayList<>();
		if (files != null) {
			for (File f : files) {
				String foundFilename = f.getName();
				if (nameComp.compare(name, foundFilename) == 0) {
					if (name.equals(foundFilename)) {
						return f;
					}
					candidateMatches.add(f);
				}
			}
		}
		Collections.sort(candidateMatches); // ensures stable results regardless if OS mutates order of listing on different runs
		return !candidateMatches.isEmpty() ? candidateMatches.get(0) : null;
	}
Looks up a file, by its string path, using a custom comparator.
<p>
If any element of the path, or the filename are not found, returns a null.
<p>
A null custom comparator avoids testing each element of the directory path and instead
relies on the native local file system's name matching.

@param baseDir optional directory to start lookup at 
@param path String path
@param nameComp optional {@link Comparator} that will compare filenames, or {@code null} 
to use native local file system lookup (eg. case-insensitive on windows)
@return File that points to the requested path, or null if file was not present on the
local filesystem (because it doesn't exist, or the name comparison function rejected it)
Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/LocalFileSystem.java