Re: Problem with chdir()

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

Juergen wrote:

<snip>



> in directory d:\, I have the following file chdir.ex:
>
> ----------------------
> file d:\\chdir.ex
> ----------------------
> include file.e
> include get.e
> integer i
>
> i = chdir("c:\\temp")
> if i then
>    printf(1, "result of chdir() is %d\n", i)
>    puts(1, "current directory is " & current_dir())
> else
>    puts(1, "error")
> end if
> i = wait_key()
> ----------------------
>
>
> When I open the directory d:\ in the explorer (under Windows 98),
> and doubleklick on chdir.ex (Euphoria 2.3 installed), I get
> the following message:
>     result of chdir is 1
>     current directory is D:\
>
> But what about the command chdir("c:\\temp")?
>
>
> When I rename the file to chdir.exw and run it, I get the message
>     result of chdir is 1
>     current directory is c:\temp
>
> as expected.
>
>
> Can anyone please tell me, what is wrong with ex.exe and chdir()?

In the case of DOS, the Euphoria manual states that the current directory is
a global property--this is not quite correct. There is a current drive, and
a current directory for EACH drive.  Apparently Eu DOS32's chdir("c:\temp")
functions the same as DOS cd c:\temp -- it changes the current directory of
the c drive, but doesn't make c: the current drive.  Either Windows or Eu
WIN32 chnages the drive automatically.  For DOS, just add

system("c:',2) before the chdir and it will give you the results you are
seeking (this is also harmless in WIN32).  [The 2 in system("c:',2) means
don't clear the screen and restore the previous graphics mode -- see the
manual.]

Perhaps Rob will make the behaviours consistent in Eu 2.4?

-- Mike Nelson

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

Search



Quick Links

User menu

Not signed in.

Misc Menu