Re: [MacPerl-Toolbox] strip the resource fork

[email protected] (Chris Nandor) Fri, 21 Mar 2003 18:11:49 -0500
Newsgroups perl.macperl.toolbox
Message-ID <p05200f05baa14be6d060@[10.0.1.104]>
http://archive.develooper.com/[email protected]/msg02178.html

>Here's another way, if you really want to destroy it and avoid copying:
>
>	use Fcntl ();
>	use POSIX ();
>
>	my $resfork = POSIX::open($file,
>		&POSIX::O_WRONLY | &POSIX::O_TRUNC | &Fcntl::O_RSRC
>	);
>	POSIX::close($resfork);
>
>This will truncate the resource fork to size 0, which essentially deletes it.

Without testing, I am fairly certain the fork will be gone.  You can test
by attempting to open the file in ResEdit to see if it asks if you want to
create a new resource fork for the file.

-- 
Chris Nandor                      [email protected]    http://pudge.net/
Open Source Development Network    [email protected]     http://osdn.com/