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

Re: [MacPerl] Porting File::PathConvert



Thanks for your reply.

Chris Nandor wrote:
> 
> 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.  :)

Already been there... it's too vague. For instance, is 
volume1:folder1:::volume2:folder2:file legal? I assume 
so, but it doesn't say. The reason I ask is that, under Win32
and VMS and for URLs, my routines don't allow you to 'back up'
in to the volume portion and switch volumes, since this is
not legal (or possible) on them. It can also be a security 
hole that lets users get out of the volume they're supposed
to be in, in a cgi script, for instance.

It doesn't talk about volume:folder1:folder2:file, either, 
but that's pretty obvious :-).

> 
> >What I'm after is a correct algorithm for adding
> >a relative path to an absolute path and ending up with a
> >correct result.
> 
> In this case, File::Spec does the right thing.
> You can look at the source of File::Spec::Mac for details.

I'm dealing with things at a slightly more automated level
than File::Spec for other filesystems, not sure if I need
to for Mac.

FWIW, I'm aiming at returning a minimal path too, so
":a:b" + "::c" yields ":a:c", not ":a:b::c". It's not that
important, but it makes for cleaner output.

I'm also not sure why File::Spec::Mac::file_name_is_absolute() 
depends on having :file exist. My guess is that it is to 
differentiate "file" from "volume". 

Also, which volume and folder are checked for -e ":file"?
This makes it difficult to work with paths that aren't
present on the local machine.

What is the exact meaning of the file spec "file"?

> 
> >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.  

I've got that already done. (File::PathConvert handles
Win32, and VMS, too).  That's actually the
easy part. The hard part is making '' (the vacuum between two
colons) look like '..' does under Unix. VMS is very similar
in that respect, though, and I think I'm very close on it.

> 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.

I already have, for other OSs, in File::PathConvert. I'm just
trolling for gotchas and odd situations that make Mac file specs
unique so I can handle things correctly.

> 
> >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.

I understand about ':::'.  Can ':name::' be transformed to ':' 
in all cases?

> 
> --
> 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