added panicIfNotFile and panicIfNotDirectory utility functions