You should probably check only opened files.
Getting meta data of all files can be expensive.