core: Fail with a better error message when list_dir gets an empty path

r? @brson (Yes, this did happen in real life...)