This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Add get_current_dir_name(3)
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Sun, 1 Jan 2012 01:46:30 -0500
- Subject: Re: [PATCH] Add get_current_dir_name(3)
- References: <1325385907.4064.7.camel@YAAKOV04>
- Reply-to: cygwin-patches at cygwin dot com
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