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

Re: [MacPerl-Toolbox] How do I parse FSSpec?



At 19:20 -0500 24/1/00, Chris Nandor wrote:
>I am not sure what you want.
>
>   use File::Basename;
>   my $file1 = 'MyHD:Mac Perl:some.pl';
>   my $dir = dirname($file);
>   my $file2 = "$dir:some.pl.copy";
>
>Is that what you want?

Almost. Following your example here is exactly what I needed:

use File::Basename;
my $file1 = 'MyHD:Mac Perl:some.pl';
my $dir = dirname($file);
my $fileName = basename ($file);
my $file2 = "$dir:$fileName" . ".copy";

Now I have a path to another file in the same folder, thanks! (and I 
can finish the *!^%*@ script!)

I still wander though, how can I parse the FSSpec returned from 
MakeFSSPec? Can the above code be written using FSSpecs?

my $file1 = 'MyHD:Mac Perl:some.pl';
$fileFSSPec = MacPerl::MakeFSSpec($file);
my $vol = ExtractVolNameFromFSSpec($fileFSSPec);
my $dir = ExtractDirNameFromFSSpec($fileFSSPec);
my $fileName = ExtractFileNameFromFSSpec ($fileFSSPec);
FSMakeFSSpec($vol, $dir, "$fileName" . ".copy");

What I don't know how to do is implement the three subs:
ExtractVolNameFromFSSpec
ExtractDirNameFromFSSpec
ExtractFileNameFromFSSpec

Any ideas?

Shai Spharim
Director of Software Development

ksWaves Ltd.
23, Kalisher St.
Tel-Aviv
Israel 65165

Email: shai@kswaves.com
Home page: http://www.waves.com
Phone +972-35107667 ext. 123
Fax +972-35105881
___________________________________________
Computers are useless. They can only give you answers.
- Pablo Picasso.

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org