in reply to Problem with opendir/readdir on Win2k

This behaviour is for historic reasons*). Both command.com and cmd.exe keep a current directory for every drive (I guess it's the underlying DOS emulation that does so). But I don't see the problem anyway, just always use drive:/ to remove any ambiguity. If your user specifies stuff like h:, they most likely mean what you will get when you call opendir( "h:" );.

*) The link is courtesy of the master of links, tilly
  • Comment on Re: Problem with opendir/readdir on Win2k

Replies are listed 'Best First'.
Re: Re: Problem with opendir/readdir on Win2k
by Rudif (Hermit) on Feb 19, 2001 at 05:26 UTC
    I realize (now that I discovered this behaviour) that the workaround is easy as you say: just always use drive:/, not drive:

    And that I must document it to users of my scripts and modules, and hope they read the doc.

    However, I consider it a bug (ok, counterintutive) because
    - in cmd.com, typing dir c: and typing dir c:\, whatever the current directory is, produces the listing of root directory of drive c (as I would expect).
    - in my tests, the behavior differs depending on the whereabouts of the perl script. Now that's something that I did not expect.

    Rudif
      I can tell you that in the Win95/NT command line "dir c:" gives you the contents of the default directory on the C: drive no matter what your current drive or directory is, and "dir c:\" is the only way to always get the root of C:.

      You can also change the current directory of a drive without "logging" (as they say) to that drive using something like "cd c:\" (this example changes the C: default dir to the root), after which "dir c:" would be equivalent to "dir c:\".

      As to the behaviour changing with the locale of the script, I think that might need a bit more investigation, I've not gone after such a bug but I also haven't notice one in many years of DOS/Win Perling...

      Update ...actually confirmed this behaviour at the NT command line also.

      --
      I'd like to be able to assign to an luser