From: Keith M. <kei...@to...> - 2006-11-09 10:06:58
|
Stefan Bellon wrote: > I'm developing an application using MinGW which has to handle file > names. On "normal" Windows everything is fine. But the application > should work under CygWin as well (i.e. it should be independent of the > environment, be it Windows or CygWin). But it doesn't cope with paths > like /cygdrive/c/foo/bar at all. Is there some way to get those paths > working as well in CygWin? Well, a path like `/cygdrive/c/foo/bar' is unlikely to work anywhere *but* in Cygwin. Thus, if you are running your application in any any other environment, you should *never* see any such Cygwin specific path. This implies that you must ensure that you do not hard code any such path within the application itself, for that is really the only way that it is likely to show up at run time, in a non-Cygwin env. FWIW, this is precisely why I recommend configuring applications in MSYS, with `--prefix=`cd /install/root; pwd -W', which ensures that the MSYS specific `/install/root' is passed through to the build process as a *native* Woe32 path -- there are some applications which encode, e.g. #define APPLICATION_ROOT "@prefix@" in a `configure' generated header; if that is translated as the MSYS specific path, in a standard MinGW application, (i.e. *not* linked with msys-1.0.dll), then it *will* fail at run time. If you are developing in Cygwin, and creating MinGW apps, then you could use `cygpath' to achieve a similar effect; the goal is to ensure that only native Woe32 paths are seen by the application, at run time. OTOH, if your goal is to run the MinGW application under Cygwin, yet allow the user to pass Cygwin paths as command line arguments, then you probably need to follow Tor Lillqvist's advice: > Well, you would have to write a function that recognizes Cygwin paths > and converts them to Win32 paths. Shouldn't be that hard. Beware *not* > to look at Cygwin's (GPL) source code when you do it. (Of course, that caveat doesn't apply, if your own application, and any derivative work, will be published under a GPL compatible license, but it is important, if you were to consider contributing to MinGW itself). In an ideal world, Cygwin would recognise that it is invoking a native Woe32 application, and would translate the path names for you, just as MSYS does. I don't use Cygwin enough to be sure what provision, if any, it makes to cope with such issues; this isn't the place to ask -- that would be on a Cygwin list. Regards, Keith. |