#! perl -w
use strict;
$|++;
sub test {
my ($dir) = @_;
print "test $dir\n";
opendir DIR, $dir or die "can't open";
my @items = readdir DIR;
closedir DIR;
print " @items\n";
}
test "."; # OK, reads the current directory
test "/"; # OK, reads the root of the curent drive
test "h:/"; # OK, reads h:/
test "c:/"; # OK, reads c:/
test "h:"; # BAD, reads the current directory when script in h:/somed
+ir
# BUT OK, reads h:/ when script in c:/somedir
test "c:"; # BAD, reads the current directory when script in c:/som
+edir
# BUT OK, reads c:/ when script in h:/somedir
__END__
Hi perlmonks of Windows obedience
Above script demonstrates what appears to be a bug in opendir/readdir,
and also in packages that rely on it, e.g. File::Find.
In offending cases,
opendir "<drive>:" from a script residing in a
subdirectory of that drive opens the current directory, not the drive
root directory.
This is on Win2k, AS perl 623.
My drives c: and h: happen to be partitions of the same physical disk -
this might or might not be relevant.
Can anyone confirm this problem (or tell me if I'm missing something subtle)?
If confirmed, would you agree that this is a bug?
Rudif
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.