Subject: | dir_list not including volume (fails round trip) |
It seems that dir_list is returning a list where the first element is
empty string where is should be the drive letter on win32 systems. I
have had a chance to test the behavior on Linux system. I attached a
test script that shows the issue.
Current work around:
my $path = dir( 'c:\windows' );
my @dir_list = $path->dir_list();
my $new_path = dir( @dir_list );
$new_path = dir( $path->volume(), @dir_list) if $path->volume();
$new_path = $new_path->cleanup();
Subject: | test_path_class_dir_list.pl |
use strict;
use warnings;
use Path::Class; # dir(), file()
use Data::Dumper;
my @test_dirs = qw{ c:\windows d:\windows };
print "=== Test round trip ===\n";
foreach ( @test_dirs ) { round_trip_test($_) }
print "=== Test adding volume ===\n";
foreach ( @test_dirs ) { add_volume_test($_) }
sub round_trip_test {
my $dir = shift;
my $test_dir = dir( $dir );
print "Test dir: '$test_dir'\n";
my @dir_list = $test_dir->dir_list();
print "dir list: " . Dumper(\@dir_list);
my $reconst_test_dir = dir( @dir_list );
print "Reconst test dir: '$reconst_test_dir'\n\n";
}
sub add_volume_test {
my $dir = shift;
my $test_dir = dir( $dir );
print "Test dir: '$test_dir'\n";
my @dir_list = $test_dir->dir_list();
my $reconst_test_dir = dir( $test_dir->volume(), @dir_list );
print "Reconst test dir: '$reconst_test_dir'\n\n";
}