This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add get_current_dir_name(3)


On Sat, Dec 31, 2011 at 08:45:07PM -0600, Yaakov (Cygwin/X) wrote:
>This patchset adds get_current_dir_name(3), a GNU extension:
>[snip]
>diff -u -p -r1.644 path.cc
>--- path.cc	24 Dec 2011 13:11:34 -0000	1.644
>+++ path.cc	27 Dec 2011 11:28:06 -0000
>@@ -2855,6 +2855,27 @@ getwd (char *buf)
>   return getcwd (buf, PATH_MAX + 1);  /*Per SuSv3!*/
> }
> 
>+extern "C" char *
>+get_current_dir_name (void)
>+{
>+  char *pwd = getenv ("PWD");
>+  char *cwd = getcwd (NULL, 0);
>+
>+  if (pwd)
>+    {
>+      struct __stat64 pwdbuf, cwdbuf;
>+      stat64 (pwd, &pwdbuf);
>+      stat64 (cwd, &cwdbuf);
>+      if (pwdbuf.st_ino == cwdbuf.st_ino)

You have to check st_dev here too don't you?

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]