1 /* Minimal 'stat' emulation: tells directories from files and
2 gives length and mtime.
3 Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
4 Updated to give more info, August 1994.
10 /* Bits in ioFlAttrib: */
11 #define LOCKBIT (1<<0) /* File locked */
12 #define DIRBIT (1<<4) /* It's a directory */
26 pb
.d
.ioNamePtr
= (unsigned char *)Pstring(path
);
30 pb
.f
.ioFVersNum
= 0; /* Fix found by Timo! See Tech Note 102 */
31 err
= PBGetCatInfoSync((CInfoPBPtr
)&pb
);
36 if (pb
.d
.ioFlAttrib
& LOCKBIT
)
40 if (pb
.d
.ioFlAttrib
& DIRBIT
) {
41 buf
->st_mode
|= 0111 | S_IFDIR
;
42 buf
->st_size
= pb
.d
.ioDrNmFls
;
46 buf
->st_mode
|= S_IFREG
;
47 if (pb
.f
.ioFlFndrInfo
.fdType
== 'APPL')
50 buf
->st_ino
= pb
.hf
.ioDirID
;
54 buf
->st_size
= (buf
->st_mode
& S_IFDIR
) ? 0 : pb
.f
.ioFlLgLen
;
55 buf
->st_mtime
= buf
->st_atime
= pb
.f
.ioFlMdDat
;
56 buf
->st_ctime
= pb
.f
.ioFlCrDat
;
57 buf
->st_rsize
= (buf
->st_mode
& S_IFDIR
) ? 0 : pb
.f
.ioFlRLgLen
;
58 *(unsigned long *)buf
->st_type
=
59 (buf
->st_mode
& S_IFDIR
) ? 0 : pb
.f
.ioFlFndrInfo
.fdType
;
60 *(unsigned long *)buf
->st_creator
=
61 (buf
->st_mode
& S_IFDIR
) ? 0 : pb
.f
.ioFlFndrInfo
.fdCreator
;