Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Path-Class CPAN distribution.

Maintainer(s)' notes

I prefer that bugs & patches are filed on GitHub rather than on RT: https://github.com/kenahoo/Path-Class/issues. Thanks.

Report information
The Basics
Id: 12148
Status: resolved
Priority: 0/
Queue: Path-Class

People
Owner: Nobody in particular
Requestors: smylers [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.08
Fixed in: (no value)



Subject: Double Backslash in C:\\Foo\Bar
Hello again. I will write the patch for that other thing, but in the meantime here's something that I reckon is an actual bug rather than a mere wishlist item. I encountered it on Windows, but here's an example using foreign_dir: % perl -MPath::Class=foreign_dir -wde0 main::(-e:1): 0 DB<1> $d = foreign_dir 'Win32', 'C:\\' DB<2> p $d C:\ DB<3> p $d->subdir('Foo/Bar') C:\\Foo\Bar There shouldn't be 2 backslashes just after the volume. The problem is that after Path::Class::Dir->new breaks C: off from C:\ for the volume, it leaves $dirs containing just a single path separator; invoking splitdir on $dirs creates two empty array items (one for the non-existent path either side of the separator), which turn into 2 backslashes when the array is concatenated for output. The attached patch contains some tests which fail with version 0.08 and a fix to make them pass. Cheers. Smylers
diff -ur -r /root/.cpan/build/Path-Class-0.08/Changes ./Changes --- /root/.cpan/build/Path-Class-0.08/Changes Tue Dec 28 14:31:32 2004 +++ ./Changes Tue Apr 5 15:26:23 2005 @@ -1,5 +1,10 @@ Revision history for Perl extension Path::Class. +0.09 not yet released + + - Fixed a bug that could result in double backslashes between the volume and + path (such as C:\\Foo\Bar). [Smylers] + 0.08 Tue Dec 28 08:26:56 CST 2004 - Fixed a typo in the module name in the docs. [Chris Dolan] diff -ur -r /root/.cpan/build/Path-Class-0.08/lib/Path/Class/Dir.pm ./lib/Path/Class/Dir.pm --- /root/.cpan/build/Path-Class-0.08/lib/Path/Class/Dir.pm Tue Dec 28 14:31:32 2004 +++ ./lib/Path/Class/Dir.pm Tue Apr 5 15:23:49 2005 @@ -18,7 +18,7 @@ ); ($self->{volume}, my $dirs) = $s->splitpath( $s->canonpath($first) , 1); - $self->{dirs} = [map $s->splitdir($_), $dirs, @_]; + $self->{dirs} = [$s->splitdir($s->catdir($dirs, @_))]; return $self; } diff -ur -r /root/.cpan/build/Path-Class-0.08/t/02-foreign.t ./t/02-foreign.t --- /root/.cpan/build/Path-Class-0.08/t/02-foreign.t Tue Dec 28 14:31:32 2004 +++ ./t/02-foreign.t Tue Apr 5 15:22:58 2005 @@ -1,6 +1,6 @@ use Test; use strict; -BEGIN { plan tests => 20 }; +BEGIN { plan tests => 24 }; use Path::Class qw(file dir foreign_file foreign_dir); ok(1); @@ -29,6 +29,13 @@ ok $dir->as_foreign('Win32'), 'dir\subdir'; ok $dir->as_foreign('Mac'), ':dir:subdir:'; ok $dir->as_foreign('OS2'), 'dir/subdir'; + +$dir = foreign_dir('Win32', 'C:\\'); +ok $dir, 'C:\\'; +$dir = foreign_dir('Win32', 'C:/'); +ok $dir, 'C:\\'; +ok $dir->subdir('Program Files'), 'C:\\Program Files'; +ok +(dir $dir, 'Program Files'), 'C:\\Program Files'; if ($^O eq 'VMS') { ok $dir->as_foreign('VMS'), '[.dir.subdir]';
From: Smylers <smylers [...] cpan.org>
After submitting the above patch I deployed it on some computers here and found the problem still existed on one of them. It turned out that that computer was still on File::Spec 0.84; it was fine on another computer with File::Spec 0.87. From reading the change log, it seems that it was version 0.86 that fixed it, so perhaps the META.yml of Path-Class should be tweaked to insist on at least File::Spec 0.86. And I meant, but forgot, to mention earlier that so far on Windows I've only been using Path::Class::Dir. It's possible that an equivalent bug exists in Path::Class::File, and my patch obviously does nothing for that. Cheers. Smylers
Thanks for the patch, this is now checked in. I also added the is_dir() method, so don't worry about that. I'm about to release a new version now. -Ken