Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/macos/source/macstat.c  view on Meta::CPAN

        err = PBHGetVInfoSync((HParmBlkPtr)&vpb);
        if (err == noErr && buf != NULL) {
            /*
             * Files are always readable by everyone.
             */
            buf->st_mode |= S_IRUSR | S_IRGRP | S_IROTH;

            /*
             * Use the Volume Info & File Info to fill out stat buf.
             */
            if (fpb.hFileInfo.ioFlAttrib & 0x10) {
                buf->st_mode |= S_IFDIR;
                buf->st_nlink = 2;
            } else {
                buf->st_nlink = 1;
                if (fpb.hFileInfo.ioFlFndrInfo.fdFlags & 0x8000) {
                    buf->st_mode |= S_IFLNK;
                } else {
                    buf->st_mode |= S_IFREG;
                }
            }
            if ((fpb.hFileInfo.ioFlAttrib & 0x10) ||
                (fpb.hFileInfo.ioFlFndrInfo.fdType == 'APPL')) {
                /*
                 * Directories and applications are executable by everyone.
                 */

                buf->st_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
            }
            if ((fpb.hFileInfo.ioFlAttrib & 0x01) == 0) {
                /*
                 * If not locked, then everyone has write acces.
                 */

                buf->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
            }
            buf->st_ino = fpb.hFileInfo.ioDirID;
            buf->st_dev = fpb.hFileInfo.ioVRefNum;
            buf->st_uid = -1;
            buf->st_gid = -1;
            buf->st_rdev = 0;

            if (CurrentFork == ResourceFork)
                buf->st_size = fpb.hFileInfo.ioFlRLgLen;
            else
                buf->st_size = fpb.hFileInfo.ioFlLgLen;

            buf->st_blksize = vpb.ioVAlBlkSiz;
            buf->st_blocks = (buf->st_size + buf->st_blksize - 1)
                            / buf->st_blksize;

            /*
             * The times returned by the Mac file system are in the
             * local time zone.  We convert them to GMT so that the
             * epoch starts from GMT.  This is also consistent with
             * what is returned from "clock seconds".
             */

            buf->st_mtime = MacFtime2UnixFtime(fpb.hFileInfo.ioFlMdDat);
            buf->st_ctime = MacFtime2UnixFtime(fpb.hFileInfo.ioFlCrDat);
            buf->st_atime = buf->st_ctime;         /* best guess */

#ifdef DEBUG_TIME
            {
            struct tm *tp = localtime(&buf->st_mtime);
            printf(
              "\nUZmacstat: local buf->st_mtime is %ld = %d/%2d/%2d  %2d:%2d:%2d",
              buf->st_mtime, tp->tm_year, tp->tm_mon+1, tp->tm_mday,
              tp->tm_hour, tp->tm_min, tp->tm_sec);
            tp = gmtime(&buf->st_mtime);
            printf(
              "\nUZmacstat: UTC   buf->st_mtime is %ld = %d/%2d/%2d  %2d:%2d:%2d\n",
              buf->st_mtime, tp->tm_year, tp->tm_mon+1, tp->tm_mday,
              tp->tm_hour, tp->tm_min, tp->tm_sec);
            }
#endif /* DEBUG_TIME */
        }
    }

    if (err != noErr) {
        errno = err;
    }

    return (err == noErr ? 0 : -1);
}



( run in 3.031 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )