public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Problem with chdir and GetCurrentDirectory on Windows 2016
@ 2016-12-07 20:23 Dipak Gaigole
  2016-12-07 20:34 ` Jeffrey Altman
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Dipak Gaigole @ 2016-12-07 20:23 UTC (permalink / raw)
  To: cygwin

Hello,

I am facing a very strange problem with chdir and GetCurrentDirectory.
After calling chdir (), the call to GetCurrentDirectory () returns
wrong value. I tested this on Windows 7 and Windows 2016. It is
working fine on Windows 7 whereas wrong values are returned on Windows
2016. I guess we should see the same behavior on Windows 10 (client
version of Windows 2016) as well.

#########################################################################
Administrator@windows2k16vika /cygdrive/c/src
$ cygcheck.exe -c cygwin
Cygwin Package Information
Package              Version        Status
cygwin               1.7.33-1       OK

Administrator@windows2k16vika /cygdrive/c/src
$ uname -a
CYGWIN_NT-10.0-WOW6 windows2k16vika 1.7.33-2(0.280/5/3) 2014-11-13
15:45 i686 Cygwin

Administrator@windows2k16vika /cygdrive/c/src
$ cat test_cwd.c
#include <stdio.h>
#include <unistd.h>
#include <windows.h>

#define BUF_SIZE 512

int main()
{
    int ret;
    char *dir;
    char dirname [BUF_SIZE];

    dir = "/cygdrive/c/Program Files";
    ret = chdir (dir);
    fprintf (stderr, "chdir (%s) reuturned <%d>\n", dir, ret);

    ret = GetCurrentDirectory(BUF_SIZE, dirname);
    if (ret)
        fprintf (stderr, "GetCurrentDirectory returned <%s>, ret =
<%d>\n", dirname, ret);

    dir = getcwd (dirname, BUF_SIZE);
    fprintf (stderr, "getcwd returned <%s>, ret = <%s>\n", dirname, dir);

    return 0;
}

Administrator@windows2k16vika /cygdrive/c/src
$ gcc -g -Wall -lKernel32 test_cwd.c  -o test_cwd

Administrator@windows2k16vika /cygdrive/c/src
$ ./test_cwd.exe
chdir (/cygdrive/c/Program Files) reuturned <0>
GetCurrentDirectory returned <C:\Pro>, ret = <6>
getcwd returned </cygdrive/c/Program Files>, ret = </cygdrive/c/Program Files>

Administrator@windows2k16vika /cygdrive/c/src
$
#########################################################################

Has anyone noticed such behavior on Windows 10 or 2016? Any
suggestions, pointers?

Thanks,
Dipak

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-12-12  9:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-07 20:23 Problem with chdir and GetCurrentDirectory on Windows 2016 Dipak Gaigole
2016-12-07 20:34 ` Jeffrey Altman
2016-12-07 21:03 ` Dipak Gaigole
2016-12-07 21:08 ` Eric Blake
2016-12-07 22:22   ` Dipak Gaigole
2016-12-07 23:06     ` Eric Blake
2016-12-07 23:52       ` Dipak Gaigole
2016-12-08 12:35         ` Dipak Gaigole
2016-12-08 18:50           ` Andrey Repin
     [not found]             ` <CADs2-=R_NxbDNom1MDyyBYgtCfifQ3V-D4jy2wNkHb7fUv0Org@mail.gmail.com>
2016-12-09  7:24               ` Dipak Gaigole
2016-12-09  8:42                 ` Csaba Raduly
2016-12-12  9:12                   ` Dipak Gaigole

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).