RE: Current Directory
- Posted by Al Getz <Xaxo at aol.com> Feb 12, 2003
- 492 views
Hello again Derek, Derek wrote: > >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... > Yes, i understand that. Switching drives was just to show that the virtual environment changes with each process, and also that is one way to view or 'get' the different 'current' directories. By switching drives like that in a dos window you can see the different directory names and verify that there really is such a notion to begin with The dos window environment doesnt forget the current directories for each drive, which is quite interesting. > >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. > When the system starts up, there is no such knowledge of *any* current directories like that, so that means your program will have all the knowledge it needs to ascertain what the user is after. At some point after your app has started up, the user had to have conveyed the directory info at some point, so you could store it in a sequence indexed by drive letter: sequence dirs,currdir dirs={"dirA","dirB","dirC",...} currdir=dirs['A'-64] or something similar to that. This should cover most platforms because you will be handling all the user interactions yourself. You should note however that you are asking quite a bit out of your user if you expect them to remember current directories for a possible 26 drives ('A' to 'Z'). That's one of the benefits of using Windows' GetOpenFilename dialog. If you absolutely cant use GetOpenFilename or whatever then you should have some way for your user to select the path from a list rather then type it in. Im sure you can come up with a way to display the necessary info? Another possible error could come up: C:\Euphoria\bin\file1.txt C:\Euphoria\Projects\bin\file1.txt User types in: "C:bin\file1.txt" Which directory are they after? Will they remember the last current directory was C:\Euphoria and not C:\Euphoria\Projects ? Since you are working with the current directories, I dont know if you are aware that the current directory is invalid for drag and dropped filenames onto the executable file? The current directory always gets set to "C:\" . This means 'current_dir()' will return "C:\" if your user drag and dropped a filename onto your executable regardless of where the executable is located or where the file was 'dragged' from. This bites i know, but it's not a Euphoria specific problem (sort of). Windows op sys doesnt return the correct directory either, nor does the respective compiled C call. Granted, it could be corrected for within the Euphoria internals however if Rob really wants to do so. Just some ideas Take care, Al