Checking file type with fstat
So I'm trying to figure out how to work this, but I'm not getting anywhere. We have an assignment where we have to sort a file we get from stdin. Part of the requirement is that we have to use fstat to get information about the file. Mainly, if it's a regular file or not. If it is, we have to allocate enough memory with malloc to store it.
The problem I'm having is figuring out how to get fstat to work correctly. I know that there's a macros S_ISREG(m) that we can check using the st_mode field...? How...? Is it a bool and how do I even access it? The problem is I can find all these documents explaining WHAT all the things are, but not how to use them. Basically, I have: Code:
struct stat buffer; Code:
if(/*is a regular file*/) |
Try 'man fstat' and take a look at the switch block in the example near the bottom.
Quote:
|
All times are GMT -5. The time now is 07:24 AM. |