- int type = entry->d_type;
- if (type == DT_LNK) {
- // find symlink target type using stat()
- struct stat s;
- if (stat(file(entry->d_name).c_str(), &s)) {
- continue; // stat() failed
- }
-
- if (S_ISDIR(s.st_mode)) {
- type = DT_DIR;
- } else if (S_ISREG(s.st_mode)) {
- type = DT_REG;
- } else {
- // symlink to block/fifo/char file, ignore
- continue;
- }
- } // of symlink look-through