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

Re: [MacPerl] More on the lack of path handling routines



The attributions are confusing, but I think Bob Dalgleish
or Scott_Ananian@sil.org wrote:
>Okay, enough grousing for now.  For this present project, it looks like
>we'll be
>able to make do with determining system type by examining @INC closely, and
>define a path separator based on that.  But I was hoping to find a more
>portable/universal solution.

Looking at @INC mightg not be reliable, since NTPerl can deal with
forward-slashes as well as backward slashes. My @INC has some of both,
including some paths that seem to mix both slashtypes.

I've gotten reliable results by testing for the existence of various root
directories. I usually say: 

if (-d '\\') {          # 'doze? (likely VMS also)
        $SL='\\';
} elsif (-d '/') {      # unicycle? (WinNT already caught)
        $SL='/';
} elsif (-d ':') {      # mac?
        $SL=':';
} else {
        die("Could not determine OS info!\n");
};

These tests are quite fast. It doesn't tell what kind of machine
(WinWhatever), but it doesn't seem necessary here. At any rate, Config.pm
could be used to determine more specific info if it was needed. 

If the source and target oses are kept as instance variables, the whole
module could be reduced down to just path(), which converted took a
source-os-style pathname and converted it to a target-os-style pathname.

Is someone already working on this module?

dan
-- 
Daniel Macks
dmacks@netspace.org
http://www.netspace.org/~dmacks