check if the path is a directory before listing its contents - fix for #...

...65 and #66

Not sure if I'm overlooking anything, but at least right now it doesn't crash any more on my installation :)