Added is_dir check

Check if $sPath is a directory before looping the DirectoryIterator.