From 370b5aded23fc3916b696569ecf3e426dca41f22 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 23 May 2002 22:36:53 +0000 Subject: [PATCH] filename.cxx changes from ppremake --- dtool/src/dtoolutil/filename.cxx | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index b345bb43bf..8e7252104f 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -52,6 +52,16 @@ #include #endif +// We might have been linked with the Cygwin dll. This is ideal if it +// is available, because it allows Panda to access all the Cygwin +// mount definitions if they are in use. If the Cygwin dll is not +// available, we fall back to our own convention for converting +// pathnames. +#ifdef HAVE_CYGWIN +extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32); +//extern "C" void cygwin_conv_to_posix_path(const char *path, char *posix); +#endif + static string front_to_back_slash(const string &str) { string result = str; @@ -85,10 +95,6 @@ get_panda_root() { if (!got_panda_root) { const char *envvar = getenv("PANDA_ROOT"); - if (envvar == (const char *)NULL) { - envvar = getenv("CYGWIN_ROOT"); - } - if (envvar != (const char *)NULL) { panda_root = front_to_back_slash(envvar); } @@ -145,10 +151,18 @@ convert_pathname(const string &unix_style_pathname) { } else { // It starts with a slash, but the first part is not a single - // letter, so prefix $PANDA_ROOT. + // letter. +#ifdef HAVE_CYGWIN + // Use Cygwin to convert it if possible. + char result[4096] = ""; + cygwin_conv_to_win32_path(unix_style_pathname.c_str(), result); + windows_pathname = result; +#else // HAVE_CYGWIN + // Without Cygwin, just prefix $PANDA_ROOT. windows_pathname = get_panda_root() + front_to_back_slash(unix_style_pathname.substr(1)); +#endif // HAVE_CYGWIN } return windows_pathname; @@ -250,7 +264,7 @@ Filename(const Filename &dirname, const Filename &basename) { //////////////////////////////////////////////////////////////////// Filename Filename:: from_os_specific(const string &os_specific, Filename::Type type) { -#if defined(WIN32) +#ifdef WIN32 string result = back_to_front_slash(os_specific); const string &panda_root = get_panda_root(); @@ -291,13 +305,12 @@ from_os_specific(const string &os_specific, Filename::Type type) { Filename filename(result); filename.set_type(type); return filename; - -#else +#else // WIN32 // Generic Unix-style filenames--no conversion necessary. Filename filename(os_specific); filename.set_type(type); return filename; -#endif +#endif // WIN32 } ////////////////////////////////////////////////////////////////////