summaryrefslogtreecommitdiffstats
path: root/Mac/Compat
diff options
context:
space:
mode:
Diffstat (limited to 'Mac/Compat')
-rw-r--r--Mac/Compat/getwd.c2
-rw-r--r--Mac/Compat/macstat.c42
-rw-r--r--Mac/Compat/macstat.h27
3 files changed, 41 insertions, 30 deletions
diff --git a/Mac/Compat/getwd.c b/Mac/Compat/getwd.c
index 3a093ed..a783ff6 100644
--- a/Mac/Compat/getwd.c
+++ b/Mac/Compat/getwd.c
@@ -27,10 +27,10 @@
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
*/
+#include "macdefs.h"
#ifdef MPW
#include <Strings.h>
#endif
-#include "macdefs.h"
#define ROOTID 2 /* Root directory ID */
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;
}
diff --git a/Mac/Compat/macstat.h b/Mac/Compat/macstat.h
index c14116a..4c24219 100644
--- a/Mac/Compat/macstat.h
+++ b/Mac/Compat/macstat.h
@@ -1,25 +1,28 @@
/* Include file belonging to stat emulator.
- Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). */
+ Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
+ Updated August 1994. */
-struct stat {
+struct macstat {
+ unsigned short st_dev;
+ unsigned long st_ino;
unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
unsigned long st_size;
- unsigned long st_rsize; /* Resource size -- nonstandard */
+ unsigned long st_atime;
unsigned long st_mtime;
+ unsigned long st_ctime;
+ /* Non-standard additions */
+ unsigned long st_rsize; /* Resource size */
+ char st_type[4]; /* File type, e.g. 'APPL' or 'TEXT' */
+ char st_creator[4]; /* File creator, e.g. 'PYTH' */
};
-#ifdef UNIX_COMPAT
#define S_IFMT 0170000L
#define S_IFDIR 0040000L
#define S_IFREG 0100000L
#define S_IREAD 0400
#define S_IWRITE 0200
#define S_IEXEC 0100
-#else
-#define S_IFMT 0xFFFF
-#define S_IFDIR 0x0000
-#define S_IFREG 0x0003
-#define S_IREAD 0400
-#define S_IWRITE 0200
-#define S_IEXEC 0100
-#endif