isdir function modified now uses fstat and S_ISDIR macro to check for directory