[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Getting size of resource forks



> I found that applications and resource files return 0 bytes!
> How can I get the total size of any file - applications,
> resource files, aliases, the Desktop and Icons.

If you can use the new PowerTools extensions, try something like
this:

use Mac::Resources;
$prev = CurResFile();
$res = OpenResFile("UNIX:Mac_Perl_510r2_a1:MiniPerl.68k") || die "$^E";
UseResFile($res);
print "Types: ", Count1Types(), "\n\n";
for ($types = Count1Types()+1; $types; --$types) {
        $type = Get1IndType($types); 
        print "Resources of type $type: ", Count1Resources($type), "\n";
        for ($rsrcs = Count1Resources($type); $rsrcs; --$rsrcs) {
                $rsrc = Get1IndResource($type, $rsrcs);
                $size = GetResourceSizeOnDisk($rsrc);
                $total += $size;
        }
}
print "Total size of all resources = $total\n";
UseResFile($prev);
CloseResFile($res);


Hopefully faster than asking the finder.


Bill