}
} Hi guys,
}
} What I'm in the process of doing at the moment, is writing a shell for DOS
} that implements unix style substitution and completion. (Just to see if I
} can :D). I've basically got it working, except for one thing.
}
} I need to be able to search through a directory, and check to see if an
} entry is a subdirectory or not. I'm using Turbo C, and I've gone through all
} the functions I could see in the header files, but couldn't find much to help
} me. Is there someone around who knows of any functions I could use, or who can
} give me an idea on the logic to use, to check for directory status?
}
} Any help is appreciated.
} Thanx in advance :)
}
Given a file handle [int fh], and a stat buffer [struct stat buf], try
---- cut 8X ----
#include <sys/types.h>
#include <sys/stat.h>
...
if ((rtn = fstat(fh, &buf)) < 0) {
perror("fstat");
} else {
if (S_ISDIR(buf.st_mode)) {
/* is a directory */
} else {
/* isn't a directory */
}
}
---- cut 8X ----
-- Colin.