Re: Current Directory

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

On Wed, 12 Feb 2003 18:21:05 -0800, Dan Moyer <DANIELMOYER at prodigy.net> 
wrote:

>
> Derek,
>
> Why not just chop apart any drive/dir info from the file names & then
> compare just the file names?  You could make a two part sequence, first 
> part
> has drive/dir portion, second part has naked filename; then start 
> comparing
> just the filenames.  If no dupl filename found, re-combine it into one 
> full
> path/filename, then compare next.  If dupl found, stop comparing it,
> re-combine its parts, go on to check next.  Each time you re-combine, put 
> it
> in another list to actually use.
>
> Dan Moyer

Thanks Dan, but that doesn't always work. For example:

  c:\autoexec.bat
and
  c:\temp\autoexec.bat
refer to the different files.

And
  c:\autoexec.bat
and
  c:\temp\..\autoexec.bat

refer to the same file.

But ...
  c:autoexec.bat

refers to a file on C: drive called "autoexec.bat" whose location is in the 
current directory for C: drive. So, how do I find the current directory for 
C: drive? The function current_dir() returns the current directory for the 
drive that was current WHEN you started the program. So if the current 
drive was D: when I started the program, current_dir() might return 
something like "D:\XYZZY\BIN". Which is no use at all if I'm trying to find 
out what the current directory for C: drive is.

Just comparing files names is obviously not going to work. Just comparing 
the user-supplied path specification is not going to work 'cos of the ".\" 
and "..\" constructs that could be present. The main difficulty is when a 
RELATIVE path is specified for a drive that is NOT the current drive - all 
the other situations I can handle.


-- 

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