summaryrefslogtreecommitdiffstats
path: root/Mac/Compat/macstat.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-08-29 08:42:37 (GMT)
committerGuido van Rossum <guido@python.org>1994-08-29 08:42:37 (GMT)
commit739267b7c34c0bdf934059804fde3f027e84bd0b (patch)
tree25dc06eae2dd9cf8b2bce19683e8d7a5b8ebbc08 /Mac/Compat/macstat.c
parente78344444086581bdf59f13415b0c701e740cce1 (diff)
downloadcpython-739267b7c34c0bdf934059804fde3f027e84bd0b.zip
cpython-739267b7c34c0bdf934059804fde3f027e84bd0b.tar.gz
cpython-739267b7c34c0bdf934059804fde3f027e84bd0b.tar.bz2
Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
versions -- they now share config.c and config.h, and statting is always done through macstat.[ch] (THINK's <stat.h> defines funny constants). Also the configuration of stdwin is done differently: you have to define USE_STDWIN to the compiler prefix.
Diffstat (limited to 'Mac/Compat/macstat.c')
-rw-r--r--Mac/Compat/macstat.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/Mac/Compat/macstat.c b/Mac/Compat/macstat.c
index e645050..564da10 100644
--- a/Mac/Compat/macstat.c
+++ b/Mac/Compat/macstat.c
@@ -1,9 +1,10 @@
/* Minimal 'stat' emulation: tells directories from files and
gives length and mtime.
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
+ Updated to give more info, August 1994.
*/
-#include "stat.h"
+#include "macstat.h"
#include "macdefs.h"
/* Bits in ioFlAttrib: */
@@ -11,9 +12,9 @@
#define DIRBIT (1<<4) /* It's a directory */
int
-stat(path, buf)
+macstat(path, buf)
char *path;
- struct stat *buf;
+ struct macstat *buf;
{
union {
DirInfo d;
@@ -23,35 +24,42 @@ stat(path, buf)
char name[256];
short err;
- pb.d.ioNamePtr= (unsigned char *)c2pstr(strcpy(name, path));
- pb.d.ioVRefNum= 0;
- pb.d.ioFDirIndex= 0;
- pb.d.ioDrDirID= 0;
- pb.f.ioFVersNum= 0; /* Fix found by Timo! See Tech Note 102 */
+ pb.d.ioNamePtr = (unsigned char *)c2pstr(strcpy(name, path));
+ pb.d.ioVRefNum = 0;
+ pb.d.ioFDirIndex = 0;
+ pb.d.ioDrDirID = 0;
+ pb.f.ioFVersNum = 0; /* Fix found by Timo! See Tech Note 102 */
if (hfsrunning())
- err= PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
+ err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
else
- err= PBGetFInfo((ParmBlkPtr)&pb, FALSE);
+ err = PBGetFInfo((ParmBlkPtr)&pb, FALSE);
if (err != noErr) {
errno = ENOENT;
return -1;
}
if (pb.d.ioFlAttrib & LOCKBIT)
- buf->st_mode= 0444;
+ buf->st_mode = 0444;
else
- buf->st_mode= 0666;
+ buf->st_mode = 0666;
if (pb.d.ioFlAttrib & DIRBIT) {
buf->st_mode |= 0111 | S_IFDIR;
- buf->st_size= pb.d.ioDrNmFls;
- buf->st_rsize= 0;
+ buf->st_size = pb.d.ioDrNmFls;
+ buf->st_rsize = 0;
}
else {
buf->st_mode |= S_IFREG;
if (pb.f.ioFlFndrInfo.fdType == 'APPL')
buf->st_mode |= 0111;
- buf->st_size= pb.f.ioFlLgLen;
- buf->st_rsize= pb.f.ioFlRLgLen;
}
- buf->st_mtime= pb.f.ioFlMdDat - TIMEDIFF;
+ buf->st_ino = pb.hf.ioDirID;
+ buf->st_nlink = 1;
+ buf->st_uid = 1;
+ buf->st_gid = 1;
+ buf->st_size = pb.f.ioFlLgLen;
+ buf->st_mtime = buf->st_atime = pb.f.ioFlMdDat;
+ buf->st_ctime = pb.f.ioFlCrDat;
+ buf->st_rsize = pb.f.ioFlRLgLen;
+ *(unsigned long *)buf->st_type = pb.f.ioFlFndrInfo.fdType;
+ *(unsigned long *)buf->st_creator = pb.f.ioFlFndrInfo.fdCreator;
return 0;
}