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 */
32 err
= PBGetCatInfoSync((CInfoPBPtr
)&pb
);
34 err
= PBGetFInfoSync((ParmBlkPtr
)&pb
);
39 if (pb
.d
.ioFlAttrib
& LOCKBIT
)
43 if (pb
.d
.ioFlAttrib
& DIRBIT
) {
44 buf
->st_mode
|= 0111 | S_IFDIR
;
45 buf
->st_size
= pb
.d
.ioDrNmFls
;
49 buf
->st_mode
|= S_IFREG
;
50 if (pb
.f
.ioFlFndrInfo
.fdType
== 'APPL')
53 buf
->st_ino
= pb
.hf
.ioDirID
;
57 buf
->st_size
= (buf
->st_mode
& S_IFDIR
) ? 0 : pb
.f
.ioFlLgLen
;
58 buf
->st_mtime
= buf
->st_atime
= pb
.f
.ioFlMdDat
;
59 buf
->st_ctime
= pb
.f
.ioFlCrDat
;
60 buf
->st_rsize
= (buf
->st_mode
& S_IFDIR
) ? 0 : pb
.f
.ioFlRLgLen
;
61 *(unsigned long *)buf
->st_type
=
62 (buf
->st_mode
& S_IFDIR
) ? 0 : pb
.f
.ioFlFndrInfo
.fdType
;
63 *(unsigned long *)buf
->st_creator
=
64 (buf
->st_mode
& S_IFDIR
) ? 0 : pb
.f
.ioFlFndrInfo
.fdCreator
;