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

Re: [MacPerl] mkpath problem



At 18.58 -0400 1999.04.07, Muggli, Ricardo T. (CCC) wrote:
>Does anyone here know how to get mkpath to work correctly using MacPerl?
>When I do something like
>mkpath("test/anotherdir/bob", 0, 0777);
>I simply get a folder named test/anotherdir/bob instead of the folder test
>with another folder in it with a bob folder in that.

As you should.  / is not a path separator on Mac OS.

>If I do
>mkpath("test:anotherdir:bob", 0, 0777);
>I get this error:
># Deep recursion on subroutine "File::Path::mkpath".File
>'10:MacPerl:lib:File:Path.pm'; Line 132Out of memory!Out of memory!Out of
>memory!

Try ":test:anotherdir:bob" instead.  In Mac OS, something that looks like
"foo:" is a volume name, not a folder in the current directory.


>I'm doing this in part to get make_metrics from Font::AFM to work. Do I have
>to replace the / in any path with : inside of the AFM.pm? If I do that I'l
>also have to change the regex parts that truncate the / etc.

The Right Way to do portable paths in Perl these days is with File::Spec.

  use File::Spec::Functions;
  mkpath(catdir(curdir(), qw(test anotherdir bob)), 0, 0777) or die $!;

As for identifying pieces of a path, File::Basename is usually the way to
go.  I don't know enough about what you are doing in Font::AFM to know.

--
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 macperl-request@macperl.org