You can probably simplify this a bit, since if it's not a dir it's a file.  The check for isFile is probably not needed, and you can just do an else with an inner if.