Create a URL clipping file

| | Comments (0)
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

use.perl.org

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on August 28, 2003 10:04 AM.

Mac::Carbon was the previous entry in this site.

Mac::Carbon Docs is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.