Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08d2071

Browse files
committed
set some fields to zero for directories
1 parent 6d47d0d commit 08d2071

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Mac/Compat/macstat.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ macstat(path, buf)
5454
buf->st_nlink = 1;
5555
buf->st_uid = 1;
5656
buf->st_gid = 1;
57-
buf->st_size = pb.f.ioFlLgLen;
57+
buf->st_size = (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlLgLen;
5858
buf->st_mtime = buf->st_atime = pb.f.ioFlMdDat;
5959
buf->st_ctime = pb.f.ioFlCrDat;
60-
buf->st_rsize = pb.f.ioFlRLgLen;
61-
*(unsigned long *)buf->st_type = pb.f.ioFlFndrInfo.fdType;
62-
*(unsigned long *)buf->st_creator = pb.f.ioFlFndrInfo.fdCreator;
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;
6365
return 0;
6466
}

0 commit comments

Comments
 (0)