Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-12 Thread Dipak Gaigole
> >> Agreed Andrey. But I couldn't find any API(s) which can serve my >> requirements. And we can't afford to execute (fork+exec) tools like >> cygpath for each getcwd call. >> Any suggestions on improving this approach or any alternative approach >> are always welcome. > > https://cygwin.com/cygwi

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-09 Thread Csaba Raduly
On Fri, Dec 9, 2016 at 8:24 AM, Dipak Gaigole wrote: > Agreed Andrey. But I couldn't find any API(s) which can serve my > requirements. And we can't afford to execute (fork+exec) tools like > cygpath for each getcwd call. > Any suggestions on improving this approach or any alternative approach >

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-08 Thread Dipak Gaigole
> > So in this situation, is it possible to get the cwd value as > "/cygdrive/c/temp/appdir/bin" using some cygwin API? > >>> > >>> No, it is generally not possible to get the POSIX path to anything in > >>> the cygwin root (/) tree to be prefixed by the /cygdrive prefix. The > >>> /

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-08 Thread Andrey Repin
Greetings, Dipak Gaigole! So in this situation, is it possible to get the cwd value as "/cygdrive/c/temp/appdir/bin" using some cygwin API? >>> >>> No, it is generally not possible to get the POSIX path to anything in >>> the cygwin root (/) tree to be prefixed by the /cygdrive pref

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-08 Thread Dipak Gaigole
>>> >>> So in this situation, is it possible to get the cwd value as >>> "/cygdrive/c/temp/appdir/bin" using some cygwin API? >> >> No, it is generally not possible to get the POSIX path to anything in >> the cygwin root (/) tree to be prefixed by the /cygdrive prefix. The >> /cygdrive prefix exist

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-07 Thread Dipak Gaigole
>> >> So in this situation, is it possible to get the cwd value as >> "/cygdrive/c/temp/appdir/bin" using some cygwin API? > > No, it is generally not possible to get the POSIX path to anything in > the cygwin root (/) tree to be prefixed by the /cygdrive prefix. The > /cygdrive prefix exists solel

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-07 Thread Eric Blake
On 12/07/2016 04:22 PM, Dipak Gaigole wrote: > C:\Temp\appdir>.\test_cwd.exe "bin" > chdir (bin) reuturned <0> > GetCurrentDirectory returned , ret = <18> > getcwd returned , ret = > > C:\Temp\appdir> > ## > Please note that I have the cygwin1.dll in t

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-07 Thread Dipak Gaigole
>> I am facing a very strange problem with chdir and GetCurrentDirectory. > > Not strange at all. The two are incompatible. When writing Cygwin > programs, stick to the POSIX-y interface, NOT the windows interface. > >> After calling chdir (), the call to GetCurrentDirectory () returns > > chdir(

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-07 Thread Eric Blake
On 12/07/2016 02:23 PM, Dipak Gaigole wrote: > Hello, > > I am facing a very strange problem with chdir and GetCurrentDirectory. Not strange at all. The two are incompatible. When writing Cygwin programs, stick to the POSIX-y interface, NOT the windows interface. > After calling chdir (), the

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-07 Thread Dipak Gaigole
> GetCurrentDirectory failed with ERROR_INVALID_HANDLE. As a result the > buffer was not populated. What is in dirname[] is stack garbage. As per the documentation of GetCurrentDirectory(), "If the function succeeds, the return value specifies the number of characters that are written to the buf

Re: Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-07 Thread Jeffrey Altman
On 12/7/2016 3:23 PM, Dipak Gaigole wrote: > GetCurrentDirectory returned , ret = <6> GetCurrentDirectory failed with ERROR_INVALID_HANDLE. As a result the buffer was not populated. What is in dirname[] is stack garbage. My guess is that /cygdrive/c/Program Files is not associated with a device

Problem with chdir and GetCurrentDirectory on Windows 2016

2016-12-07 Thread Dipak Gaigole
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 s