Replace use of d_type member of struct dirent with stat()

Illumos does not have the d_type member in struct dirent. To be more
portable,

this web page:

http://stackoverflow.com/questions/2197918/cross-platform-way-of-testing-whether-a-file-is-a-directory

recommends converting code like this:

    if (de->d_type == DT_DIR)
    {
       return 0;
    }

to this:

    struct stat s; /*include sys/stat.h if necessary */
    ..
    ..
    stat(de->d_name, &s);
    if (s.st_mode & S_IFDIR)
    {
        return 0;
    }
Same as above comments: ::stat and != -1.