This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 1.7] Can you have multipe cygdrive path prefixes active at once


aputerguy wrote:
> Jeremy Bopp wrote:
>> aputerguy wrote:
>>> In particular, I can't use "mount -p" to distinguish between prefixes
>>> that
>>> might have (variable) number of trailing spaces (which is allowed).
>> I believe that you want to use the cygpath program if you want to
>> convert POSIX paths to Windows paths reliably.  Assuming the default
>> cygdrive prefix is in use:
>>
>> $ cygpath -w /cygdrive/c/an/example/posix/path
>> C:\an\example\posix\path
> 
> All true and known. BUT I want to know the cygdrive prefix in general for
> use in future constructions rather than just making a single path. Say if I
> want to find all files, I want to do something like "find <cygdrive-prefix>

Well, it's a bit of a hack, but you could try something like the following:

$ dirname $(cygpath -u C:/)

This assumes that there is always a C: drive and converts the path to
the root of that drive into a POSIX path which will include the cygdrive
prefix.  Then dirname is used to effectively chop off the drive letter
leaving you with the cygdrive prefix.

If you're thinking that you can run something like ls or find the
cygdrive prefix and enumerate all of the drives on the system, you
should know that it won't work in some cases, such as when someone sets
their cygdrive prefix to "/".  In this case, the drives are still
available explicitly as /c, /d, etc. but they will not be enumerated by
"ls /" or "find /".

-Jeremy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]