Re: Opening a file - File Open Dialog spoils future code

new topic     » goto parent     » topic index » view thread      » older message » newer message

Matt Lewis wrote:
> 
> CChris wrote:
> > 
> > open() doesn't understand Windows folders, because Windows doesn't have a
> > notion
> > of a current directory. open() uses the PATH environment variable, which is
> > a DOS/Unix thing Windows supports for backward compatibility only) and looks
> > for MyFileName.CFG in places completely different from where Windows looks
> > for
> > them, so it probably just can't see the file there.
> 
> I thought that it did, and that %PATH is only used for executables and for
> dlls.  What do current_dir() and chdir() do then?
> 
> Matt

All right, I should have checked first, but the bottom line is the same: never
use current_dir() under Windows. Here is what I found on MSDN:
<quote>
The directory at the end of the active path is called the current directory; it
is the directory in which the active application started, unless explicitly
changed. An application can determine which directory is current by calling the
GetCurrentDirectory function.

An application can change the current directory by calling the
SetCurrentDirectory function.
</quote>

I have recently wondered why I wasn't finding ex.err after a program crash.
Searching ex.err on my machine reported 9 different directories, some of which
I'd havd never thought about. Since ex.err is created using open("ex.err","w"), I
consider the "current directory" to be undefined for practical use: it is
defined, but as something volatile (what is the active application on a
multiprocess platform?). I'd go as far as recommending to drop support of
current_dir() and chdir() under Windows.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu