Your check does not determine if the path actually is a directory... it could be a bogus stream or a file or something like that. On other note, I'll borrow from your implementation to list all non writable dirs :-)