Re: Current Directory

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

----- Original Message -----
From: "Al Getz" <Xaxo at aol.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Current Directory


>
>
> Derek Parnell wrote:
> > In Windows and DOS environments, how can I get Euphoria to tell me the
> > current directory of a drive that is not the current drive?
> >
> > My understanding is that each drive in a DOS/Windows system has its own
> > current directory setting. I know that current_dir() will give me the
> > directory that I started running the Euphoria program from, but how do I
> >
> > find the current diretory of any of the other drives.
> >
> > If possible, I'd prefer NOT to use a Windows API or DOS interrupt to get
> >
> > the info.
> >
> > In fact, what I'm trying to do is write a function that is given a
> > filepath
> > string, and have it return the same path but in standardized - full -
> > form.
> > This should take into consideration any ".\" and "..\" and leading
> > "DRIVE:"
> > combinations. I've almost succeeded except for paths given in the form
> > ...
> >
> >     P:myfolder\myfile.abc
> >
> > I know the drive "P:" but the rest is supplied relative to the current
> > directory *on that drive*! And now I need to know how to get that info.
> >
> > Maybe somebody has already got a neat function that does all this (hint,
> >
> > hint).
> >
> > I'm not even going to try network paths yet blink
> > --
> >
> > cheers,
> > Derek Parnell
> >
> >
> Hello there,
>
> Is there really such a thing in general?
>
> After all, if you open a dos window and at the c:\> prompt type
> D:\
> and then type
> cd "Euphoria"
>
> then type
> C:
> you get the C prompt back, and then type
> D:
> you get the D prompt with the previous 'switched to' directory
> "D:\Euphoria>"
> (as expected)
>
> BUT
>
> if you leave that window open and open another dos window and
> at the C prompt type
> D:
> you get
> "D:\>"
> even though the previous dos window still shows "D:\Euphoria>"
> which means there is no such thing as a 'system wide' current
> directory for each drive and that the current directory is
> particular to the process only.
> This also implies that each process can have it's own current
> directory which has nothing to do with the other processes'.
>
> As is you cant run multiple statements with the 'system' command
> like:
> system("doscommand1,doscommand2, doscommand3",0)
> either, which ideally would run several commands in the
> same dos window.
>
> If you try using a .bat file im pretty sure once the bat file
> stops running all the current directory info is lost anyway,
> so you would have to do all the work within the bat file.
>
> There is nothing to stop you from starting your own 'driver'
> that will keep track of 'current directories' for each drive
> (of course you will have to override a few functions prepending
> the current directory),
> but i think if you look into the original problem you will
> find a better way to do it overall then having to deal with
> multiple current directories.
>
> What is the original problem that prompted you to look for
> the 'current directory' for each drive?
>
> Let us know what you end up doing.

Al,
yes I realize all that you have said is true. But That is NOT what I'm
interested in. I'm NOT trying to change directories or drives. As I said in
my original request...

> > In fact, what I'm trying to do is write a function that is given a
> > filepath
> > string, and have it return the same path but in standardized - full -
> > form.
> > This should take into consideration any ".\" and "..\" and leading
> > "DRIVE:"
> > combinations. I've almost succeeded except for paths given in the form
> > ...
> >
> >     P:myfolder\myfile.abc

I just want to detect if a user supplied file has been already 'seen'
before. I thought that if I converted whatever the user supplied to a
standard form - the FULL path specification - all I have to do then is
compare the two specs to see if they are really the same. For instance...

  C:\autoexec.bat
and
  C:\temp\..\autoexec.bat

refer to the same file even though the USER supplied path's are different.

My problem is in situation where the current drive is say C: and the user
enters "P:bin\xyz.zzy" meaning that the file they want is on the P drive is
is relative to the current directory *for that drive* and not the C: drive.


----------------
cheers,
Derek Parnell

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

Search



Quick Links

User menu

Not signed in.

Misc Menu