]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
set some fields to zero for directories
authorGuido van Rossum <guido@python.org>
Tue, 8 Aug 1995 14:09:33 +0000 (14:09 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 8 Aug 1995 14:09:33 +0000 (14:09 +0000)
Mac/Compat/macstat.c

index 0f690e098cb3c91ca7d9bccefaec97374af8436c..a1265afbd7fcb53fe5ce8b2d69504f917e71f168 100644 (file)
@@ -54,11 +54,13 @@ macstat(path, buf)
        buf->st_nlink = 1;
        buf->st_uid = 1;
        buf->st_gid = 1;
-       buf->st_size = pb.f.ioFlLgLen;
+       buf->st_size = (buf->st_mode & S_IFDIR) ? 0 : 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;
+       buf->st_rsize = (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlRLgLen;
+       *(unsigned long *)buf->st_type =
+               (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlFndrInfo.fdType;
+       *(unsigned long *)buf->st_creator =
+               (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlFndrInfo.fdCreator;
        return 0;
 }