From: dannysmith Date: Thu, 18 Apr 2002 10:32:26 +0000 (+0000) Subject: * dirent.c (opendir): Convert given pathname to X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=72ef0661056c91dea939f210b7efaab7b174fd18;p=pf3gnuchains%2Fpf3gnuchains3x.git * dirent.c (opendir): Convert given pathname to absolute pathname. --- diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index 0eb8c5af78..3034be6858 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,8 @@ +2002-04-18 Pascal Obry + + * dirent.c (opendir): Convert given pathname to + absolute pathname. + 2002-04-09 Earnie Boyd * include/_mingw.h: Increment version. diff --git a/winsup/mingw/dirent.c b/winsup/mingw/dirent.c index e3885f0eac..9eb1a502cc 100644 --- a/winsup/mingw/dirent.c +++ b/winsup/mingw/dirent.c @@ -40,6 +40,7 @@ opendir (const char *szPath) { DIR *nd; unsigned int rc; + char szFullPath[MAX_PATH]; errno = 0; @@ -56,7 +57,7 @@ opendir (const char *szPath) } /* Attempt to determine if the given path really is a directory. */ - rc = GetFileAttributes(szPath); + rc = GetFileAttributes (szPath); if (rc == -1) { /* call GetLastError for more error info */ @@ -70,9 +71,12 @@ opendir (const char *szPath) return (DIR *) 0; } + /* Make an absolute pathname. */ + _fullpath (szFullPath, szPath, MAX_PATH); + /* Allocate enough space to store DIR structure and the complete * directory path given. */ - nd = (DIR *) malloc (sizeof (DIR) + strlen (szPath) + strlen (SLASH) + + nd = (DIR *) malloc (sizeof (DIR) + strlen (szFullPath) + strlen (SLASH) + strlen (SUFFIX)); if (!nd) @@ -83,7 +87,7 @@ opendir (const char *szPath) } /* Create the search expression. */ - strcpy (nd->dd_name, szPath); + strcpy (nd->dd_name, szFullPath); /* Add on a slash if the path does not end with one. */ if (nd->dd_name[0] != '\0' &&