Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowi@redhat.com>2012-01-01 22:54:25 +0400
committerYaakov Selkowitz <yselkowi@redhat.com>2012-01-01 22:54:25 +0400
commit0b5355f17c5be3f3b565dc4bc257b7f153ac42a5 (patch)
treeb848c4aa19139d8f75f3a0331ce9e86bce81f375 /winsup/cygwin/path.cc
parentd27d202f56682f6f01903790a84de1e9cca9aced (diff)
* cygwin.din (get_current_dir_name): Export.
* path.cc (get_current_dir_name): New function. * posix.sgml (std-gnu): Add get_current_dir_name. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 0b8539065..7dc85442e 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -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_dev == cwdbuf.st_dev) && (pwdbuf.st_ino == cwdbuf.st_ino))
+ {
+ cwd = (char *) malloc (strlen (pwd) + 1);
+ strcpy (cwd, pwd);
+ }
+ }
+
+ return cwd;
+}
+
/* chdir: POSIX 5.2.1.1 */
extern "C" int
chdir (const char *in_dir)