* cygwin_conv_path strange behavior
@ 2012-06-27 11:59 Jan Nijtmans
2012-06-27 12:11 ` Earnie Boyd
2012-06-27 12:30 ` Corinna Vinschen
0 siblings, 2 replies; 4+ messages in thread
From: Jan Nijtmans @ 2012-06-27 11:59 UTC (permalink / raw)
To: cygwin
Dear cygwin developers.
When trying the function cygwin_conv_path, I noted
some strange effect, when the cygwin1.dll is in the
same directory as the executable. This can be
demonstrated with the example "mypath.c" below.
Compiling this function, and putting it in some
directory "C:\some\path\foo', from a cygwin shell,
it prints:
$ ./mypath
win32 path: C:\some\path\foo\mypath.exe
posix path: /cygdrive/c/some/path/foo/mypath.exe
From a win32 command shell:
> .\mypath
win32 path: C:\some\path\foo\mypath.exe
posix path: /cygdrive/c/some/path/foo/mypath.exe
This is as expected.
Now, copy cygwin1.dll to the same directory
as mypath.exe, and do the same
from a cygwin shell, it prints:
$ ./mypath
win32 path: C:\some\path\foo\mypath.exe
posix path: /cygdrive/c/some/path/foo/mypath.exe
From a win32 command shell:
> .\mypath
win32 path: C:\some\path\foo\mypath.exe
posix path: /foo/mypath.exe
In other words, the first part of the posix path is
stripped, when running it from a win32 shell!
My objective is to distribute "mypath.exe" separate
from cygwin, simply by putting cygwin1.dll (the only
one it needs) in the same directory as the executable,
so it can run without the presence of the cygwin
environment. But this results in wrong paths produced
by the cygwin_conv_path() function.
Is this a bug in cygwin_conv_path()? What can
I do about that?
Regards,
Jan Nijtmans
=============== mypath.c =================
extern __stdcall int GetModuleFileNameA(void *, const char *, int);
#define PATH_MAX 512
int
main ()
{
char buf[PATH_MAX];
char name[PATH_MAX];
GetModuleFileNameA(0, buf, PATH_MAX);
cygwin_conv_path(2, buf, name, PATH_MAX);
printf("win32 path: %s\nposix path: %s\n", buf, name);
}
--
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] 4+ messages in thread
* Re: cygwin_conv_path strange behavior
2012-06-27 11:59 cygwin_conv_path strange behavior Jan Nijtmans
@ 2012-06-27 12:11 ` Earnie Boyd
2012-06-27 12:29 ` Jan Nijtmans
2012-06-27 12:30 ` Corinna Vinschen
1 sibling, 1 reply; 4+ messages in thread
From: Earnie Boyd @ 2012-06-27 12:11 UTC (permalink / raw)
To: cygwin
On Wed, Jun 27, 2012 at 7:59 AM, Jan Nijtmans wrote:
>
> Now, copy cygwin1.dll to the same directory
> as mypath.exe, and do the same
> from a cygwin shell, it prints:
> $ ./mypath
> win32 path: C:\some\path\foo\mypath.exe
> posix path: /cygdrive/c/some/path/foo/mypath.exe
> From a win32 command shell:
> > .\mypath
> win32 path: C:\some\path\foo\mypath.exe
> posix path: /foo/mypath.exe
>
This sounds it is as expected. You copied only cygwin1.dll so the
shell you started had a cygwin1.dll in another directory so that / is
mapped to the parent directory containing the cygwin1.dll the shell is
using. However, when you use the win32 command shell there is no
previous mapping of / to the parent directory containing cygwin1.dll
so / is mapped to c:/some/path and the function correctly reports
/foo/mypath.exe.
--
Earnie
-- https://sites.google.com/site/earnieboyd
--
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] 4+ messages in thread
* Re: cygwin_conv_path strange behavior
2012-06-27 12:11 ` Earnie Boyd
@ 2012-06-27 12:29 ` Jan Nijtmans
0 siblings, 0 replies; 4+ messages in thread
From: Jan Nijtmans @ 2012-06-27 12:29 UTC (permalink / raw)
To: cygwin
2012/6/27 Earnie Boyd <earnie@users.sourceforge.net>:
> On Wed, Jun 27, 2012 at 7:59 AM, Jan Nijtmans wrote:
>>
>> Now, copy cygwin1.dll to the same directory
>> as mypath.exe, and do the same
>> from a cygwin shell, it prints:
>> $ ./mypath
>> win32 path: C:\some\path\foo\mypath.exe
>> posix path: /cygdrive/c/some/path/foo/mypath.exe
>> From a win32 command shell:
>> > .\mypath
>> win32 path: C:\some\path\foo\mypath.exe
>> posix path: /foo/mypath.exe
>>
>
> This sounds it is as expected. You copied only cygwin1.dll so the
> shell you started had a cygwin1.dll in another directory so that / is
> mapped to the parent directory containing the cygwin1.dll the shell is
> using. However, when you use the win32 command shell there is no
> previous mapping of / to the parent directory containing cygwin1.dll
> so / is mapped to c:/some/path and the function correctly reports
> /foo/mypath.exe.
OK, so cygwin1.dll always maps "/" to its parent directory, if no other
mapping can be found. But from a win32 command shell, I don't
need such a mapping, I just want to know the full path
where the executable is. How can I influence that?
Thanks!
Regards,
Jan Nijtmans
--
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] 4+ messages in thread
* Re: cygwin_conv_path strange behavior
2012-06-27 11:59 cygwin_conv_path strange behavior Jan Nijtmans
2012-06-27 12:11 ` Earnie Boyd
@ 2012-06-27 12:30 ` Corinna Vinschen
1 sibling, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2012-06-27 12:30 UTC (permalink / raw)
To: cygwin
On Jun 27 13:59, Jan Nijtmans wrote:
> My objective is to distribute "mypath.exe" separate
> from cygwin, simply by putting cygwin1.dll (the only
> one it needs) in the same directory as the executable,
"Distribute?"
http://cygwin.com/licensing.html
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
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] 4+ messages in thread
end of thread, other threads:[~2012-06-27 12:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 11:59 cygwin_conv_path strange behavior Jan Nijtmans
2012-06-27 12:11 ` Earnie Boyd
2012-06-27 12:29 ` Jan Nijtmans
2012-06-27 12:30 ` Corinna Vinschen
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).