Create a URL clipping file

pudge on 2003-08-28T17:04:58

There are three resources in the clipping I got from Safari: TEXT, url, and drag. TEXT and url are the same, and TEXT doesn't seem to do anything. Neither does drag, so I just put in the url resource, which seems to work just fine. If more is needed, it can be added. (Note: you can use DeRez to see what is in a resource file, in /Developer/Tools/ or somesuch).

So anyway, this little bit of code works for me, share and enjoy. Mac::Carbon required.

#!/usr/local/bin/perl use strict; use warnings;

use File::Spec::Functions; use Mac::Errors '$MacError'; use Mac::Files; use Mac::Memory; use Mac::Resources;

my $url = new Handle "http://projects.pudge.net/"; my $file = catfile(FindFolder(kUserDomain, kDesktopFolderType), "projects.webloc");

FSpCreateResFile($file, 'MACS', 'ilht', 0) or die $MacError; my $RF = FSpOpenResFile($file, 0) or die $MacError;

AddResource($url, 'url ', 256, '');

UpdateResFile($RF); CloseResFile($RF);

Now Playing: Desire - U2