Re: using stat
Re: using stat
- Subject: Re: using stat
- From: Shantonu Sen <email@hidden>
- Date: Sun, 12 Sep 2004 08:38:55 -0700
You are confused about what this field contains. returning 0 is normal
for that field. See chflags(2) for typical contents. From <sys/stat.h>:
/*
* Definitions of flags stored in file flags word.
*
* Super-user and owner changeable flags.
*/
#define UF_SETTABLE 0x0000ffff /* mask of owner changeable
flags */
#define UF_NODUMP 0x00000001 /* do not dump file */
#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
#define UF_APPEND 0x00000004 /* writes to file may only
append */
#define UF_OPAQUE 0x00000008 /* directory is opaque wrt.
union */
/*
* Super-user changeable flags.
*/
#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable
flags */
#define SF_ARCHIVED 0x00010000 /* file is archived */
#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
#define SF_APPEND 0x00040000 /* writes to file may only
append */
None of these are typically set for files or directories.
You can determine if you have a directory by doing:
if(S_ISDIR(stat_buf.st_mode))
This is not Darwin specific... You may want to check out a unix program
text on this matter for further information.
Shantonu
On Sep 12, 2004, at 1:27 AM, Hugh Hoover wrote:
Hi - I'm attempting to use stat on 10.3.5 and getting back strange
results...
The first items in the result stat_buf struct seems more or less
correct, dev, inode, uid, gid, times, size, etc.
The nlinks field seems suspicious, but the killer is the st_flags
field - it's ALWAYS 0 - even for directories (which is why I'm doing
the stat - to find out if I have a directory or not).
I've checked the sys/stat.h header and everything appears to be in
order there. I'm pretty sure I've got the right set of headers (for
10.3).
Any suggestions?
TIA
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >using stat (From: Hugh Hoover <email@hidden>) |