#!perl # Script to test MacPerl stat() and file test operators foreach $f (@ARGV) { ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($f); print "\nstat() call on [$f]-------------------->\n"; print "dev =$dev\n"; print "ino =$ino\n"; print "mode =$mode\n"; print "nlink =$nlink\n"; print "uid =$uid\n"; print "gid =$gid\n"; print "rdev =$rdev\n"; print "size =$size\n"; print "atime =$atime\n"; print "mtime =$mtime\n"; print "ctime =$ctime\n"; print "blksize=$blksize\n"; print "blocks =$blocks\n"; print "\nFile test results:\n"; print "-r test (Readable by effective uid) = [". (-r $f) . "]\n"; print "-w test (Writable by effective uid) = [". (-w $f) . "]\n"; print "-x test (Executable by effective uid) = [". (-x $f) . "]\n"; print "-o test (Owned by effective uid) = [". (-o $f) . "]\n"; print "-R test (Readable by real uid) = [". (-R $f) . "]\n"; print "-W test (Writable by real uid) = [". (-W $f) . "]\n"; print "-X test (Executable by real uid) = [". (-X $f) . "]\n"; print "-O test (Owned by real uid) = [". (-O $f) . "]\n"; print "-e test (File exists) = [". (-e $f) . "]\n"; print "-z test (File has zero size) = [". (-z $f) . "]\n"; print "-s test (File has non-zero size) = [". (-s $f) . "]\n"; print "-f test (File is a plain file) = [". (-f $f) . "]\n"; print "-d test (File is a directory) = [". (-d $f) . "]\n"; print "-l test (File is a symbolic link ie. a Finder alias) = [". (-l $f) . "]\n"; print "-S test (File is a socket handle) = [". (-S $f) . "]\n"; print "-p test (File is a named pipe) = [". (-p $f) . "]\n"; print "-b test (File is a block special file) = [". (-b $f) . "]\n"; print "-c test (File is a char special file) = [". (-c $f) . "]\n"; print "-u test (File has setuid bit set) = [". (-u $f) . "]\n"; print "-g test (File has setgid bit set) = [". (-g $f) . "]\n"; print "-k test (File has sticky bit set) = [". (-k $f) . "]\n"; print "-t test (Filehandle opened to a tty eg.Dev:Console) = [". (-t $f) . "]\n"; print "-T test (File is a TEXT file) = [". (-T $f) . "]\n"; print "-B test (File is a BINARY file) = [". (-B $f) . "]\n"; print "-M test (Unix: Age; Mac: Last modified; \n"; print " both in days since script executed) = [". (-M $f) . "]\n"; print "-A test (Unix: Access, as per -M; Mac: as per -M) = [". (-A $f) . "]\n"; print "-C test (Unix: Inode changed, as per -M;\n"; print " Mac: Created; both in days)) = [". (-C $f) . "]\n"; ($creator, $type) = &MacPerl'GetFileInfo($f); print "\nMac creator=[$creator] Mac type=[$type]\n"; }