Looks like methods calling this method check if dir is a directory before calling listFiles. Consider adding documentation or adding the check so that it's clear.