develooper Front page | perl.perl5.porters | Postings from February 2013

Re: File::Spec in XS

Thread Previous | Thread Next
Craig A. Berry
February 28, 2013 18:30
Re: File::Spec in XS
Message ID:
On Thu, Feb 28, 2013 at 11:53 AM, Zefram <> wrote:
> Craig A. Berry wrote:
>>So the code paths where invocant_is_unix() is false are still
>>File::Spec::Unix but only via inheritance?
> Can't quite parse your question.  The invocant_is_unix() check is to
> distinguish direct use of File::Spec::Unix from inherited use of its
> methods.  The code paths resulting from !invocant_is_unix() are the ones
> that play nicely in composition, specifically by calling other methods
> (that may have been overridden) rather than assuming that the methods
> would be the Unix versions.

So in your catfile implementation in the path where invocant_is_unix()
is false, you have:

+	    call_method("catdir", G_SCALAR);
+	    SPAGAIN;
+	    dir = POPs;
+	    LEAVE;
+	    pv = SvPV(dir, len);
+	    need_slash = len == 0 || pv[len-1] != '/';
+	    RETVAL = newSVsv(dir);

Are you saying that "catdir" you're calling could be
File::Spec::VMS::catdir or File::Spec::Win32::catdir?  If so, this is
completely wrong, at least in the VMS case, because there is no way to
implement catfile in terms of catdir -- file and directory syntax are
completely different.  And checking for literal slashes might not do
what you expect when slashes are not the directory delimiter.

But hopefully (and more likely) I simply misunderstand how the
inheritance works.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About