- Improved realpath() wrapper in media handler class (#222521).
authorMarius Tomaschewski <mt@suse.de>
Thu, 7 Dec 2006 09:37:02 +0000 (09:37 +0000)
committerMarius Tomaschewski <mt@suse.de>
Thu, 7 Dec 2006 09:37:02 +0000 (09:37 +0000)
package/libzypp.changes
zypp/media/MediaHandler.cc

index f38d98b..4cf5de1 100644 (file)
@@ -2,7 +2,7 @@
 Mon Dec  4 15:38:12 CET 2006 - mt@suse.de
 
 - Improved realpath() wrapper in media handler class (#222521).
-- revision 4737
+- revision 4758
 
 -------------------------------------------------------------------
 Thu Nov 30 09:15:20 CET 2006 - ma@suse.de
index 0b56247..982437e 100644 (file)
@@ -21,6 +21,8 @@
 #include "zypp/media/Mount.h"
 #include <limits.h>
 #include <stdlib.h>
+#include <errno.h>
+
 
 using namespace std;
 
@@ -119,12 +121,24 @@ MediaHandler::getRealPath(const std::string &path)
   if( !path.empty())
   {
 #if __GNUC__ > 2
+    /** GNU extension */
     char *ptr = ::realpath(path.c_str(), NULL);
     if( ptr != NULL)
     {
       real = ptr;
       free( ptr);
     }
+    else
+    /** the SUSv2 way */
+    if( EINVAL == errno)
+    {
+      char buff[PATH_MAX + 2];
+      memset(buff, '\0', sizeof(buff));
+      if( ::realpath(path.c_str(), buff) != NULL)
+      {
+       real = buff;
+      }
+    }
 #else
     char buff[PATH_MAX + 2];
     memset(buff, '\0', sizeof(buff));