Just today, I found my first real need for Mac::Carbon in my daily work, 
since I started the port.

I have a review of EyeTV (http://www.elgato.com/eyetv/) on Slashdot 
today; while writing it, I was bemoaning the fact that it is hard to 
find which EyeTV files are which, as the filenames don't give any clue.  
Noting that the files in question are plist files, I set about to 
writing a solution this morning, to finish it in time for the review. :-)

The finished product is at http://dev.macperl.org/files/scripts/eyetv 
... but the part where Carbon helped me is below.  The path to the EyeTV 
folder is stored as alias data in the EyeTV prefs, and it needed to be 
turned into a path so I could open the directory and look at the files.

So Mac::Files::FindFolder() finds the preferences directory, Mac::Memory 
puts the alias data into a memory handle, and Mac::Files::ResolveAlias() 
turns it into a path.  Mmmmm, Carbon-licious.  Enjoy!


use Mac::Files;
use Mac::Memory;

# ...

if (!$eyetvdir) {
   # find proper file from preferences, it's a Base64'd alias,
   # so get the data, stick it in a handle, and resolve it
   my $prefs = catfile(
      FindFolder(kOnSystemDisk, kPreferencesFolderType),
      'com.elgato.eyetv.plist'
   );

   # opens the plist file, gets the data, parses with Mac::PropertyList
   my $data   = get_plist($prefs);
   my $handle = new Handle $data->{value}{'archive folder'}{value};

   $eyetvdir = catdir(scalar ResolveAlias($handle), 'EyeTV Archive');
}


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

Reply via email to