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

Re: [MacPerl] Porting File::PathConvert



At 23.50 -0500 1999.02.02, Barrie Slaymaker wrote:
>I have coded in some guesses as to how to work with MacOS paths, but
>I don't have a mac, let alone MacPerl to work things out on.

First thing I would suggest is using File::Spec.  You don't need to be on a
Mac to test it.

   BEGIN{$^O = 'MacOS'}
   use File::Spec;
   print File::Spec->catfile('a', 'b');

Also, the details of paths on Mac OS are specified in the Mac section of
perlport.pod, in a perl5.005 or CPAN site near you.  :)

>What I'm after is a correct algorithm for adding
>a relative path to an absolute path and ending up with a
>correct result.

Is this what you mean?

  $abs = 'HD:some:path';
  $rel = ':some:other:path:';

In this case, File::Spec does the right thing.

  BEGIN{$^O = 'MacOS'}
  use File::Spec;
  print File::Spec->catfile($abs, $rel)

You can look at the source of File::Spec::Mac for details.

>And another one for subtracting two absolute
>paths to get the relative path from one to the other.

Hm, that one's a bit trickier.  Especially since Mac OS has
case-insensitive filenames.  It's a bit early in the morning for me to try
this, perhaps someone else can try.  Or, if you want to have a go, you can
ask us to have a look at it.


>And any suggestions for converting paths to a minimal canonical
>form. For instance, under Unix-lie filesystems, '/name/..'
>and '/////' are both removed.

No such thing in Mac OS.  :: means to go back one directory. ::: means go
back two directories.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch