This is the mail archive of the cygwin 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: Problem with chdir and GetCurrentDirectory on Windows 2016


> >>>>
> >>>> 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 solely to resolve paths that are outside of /,
> >>> so paths inside that tree don't need the /cygdrive prefix.
> >>>
> >> This path is also displayed to the enduser at different places. So our
> >> requirement is to always get a path in the /cygdrive/ prefix format
> >> irrespective of whether it is inside the cygwin root (/) or outside of
> >> /.
>
> > I think this can be achieved by getcwd () +
> > cygwin_conv_path(CCP_POSIX_TO_WIN_A,...) and converting the windows
> > style path to /cygdrive/ prefix format.
>
> No, this is wrong approach.
> Do not do manual path manipulation, it WILL fail.
> Always use corrsponding conversion tools provided by Cygwin.

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.

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


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