Georg Baum a écrit :
Abdelrazak Younes wrote:
Abdelrazak Younes a écrit :
#include <unistd.h>
bool isCygwin()
{
return access("/cygdrive", F_OK) == 0;
}
Just for confirmation, is /cygdrive is present on any cygwin
installation? But in the special case where a user has a c:\cygdrive and
lyx is installed on the same drive, this test doesn't work (I just made
the test). Is there any other way?
"/usr/bin/cygstart.exe" seems to be a good candidates... Any objection
if I replace the #ifdef with this test in the Qt4 frontend?
Please not.
Ah... At least someone is listening to me :-)
This is a hack. It is not impossible to have
a /usr/bin/cygstart.exe on any unix box. Then your test will fail.
OK, then:
inline bool isCygwin()
{
#ifdef WIN32
return access("/usr/bin/cygstart.exe", F_OK) == 0;
#endif
return false;
}
This call will cost virtually no CPU and should be eliminated by a good
compiler.
I don't understand what is wrong with an #ifdef? I personally prefer always
compiletime checks rather than runtime checks if it is possible. Why do a
hackish runtime test if the same thing can be achieved at compile time?
In this case, the goal would be have a universal windows binary.
Of course the #ifdefs should not be scattered around, but isolated in few
utility functions. For this reason we have introduced the various ...path()
functions, and this works quite well.
Agreed. I just want to minimize the #ifdef to a unique support file.
I did not yet have time to comment on Enricos patch, I just had a quick look
and the cygwin ifdefs he introduced in frontends/qt2/FileDialog.C don't
seem right. If they are really needed (which I doubt currently, but that
may change after reading the whole patch) we should introduce just another
patch function. That way, we get nice clean code and the ugly stuff is
banned to few files in src/support.
OK.
Abdel.