RE: Current Directory
- Posted by Al Getz <Xaxo at aol.com> Feb 12, 2003
- 525 views
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 > -- > > 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. Take care, Al