Properly handle empty directories.