This is the mail archive of the
mailing list for the Cygwin project.
Re: GCC and getcwd
- From: "Larry Hall (RFK Partners, Inc)" <lhall at rfk dot com>
- To: Sami Tikka <sami dot tikka at welho dot com>, Francis Harvey <HARVEYF1 at WESTAT dot com>
- Cc: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Thu, 31 Jan 2002 18:08:33 -0500
- Subject: Re: GCC and getcwd
- References: <08B08C9FA5EBD311A2CC009027D5BF81032B0F9E@remailnt2-re01.westat.com>
At 05:55 PM 1/31/2002, Sami Tikka wrote:
>Francis Harvey wrote:
>>I want to find the current directory that the executable file is in,
>>so I can open a text file in the same directory. The executable
>>is on the k drive, but my code doesn't return the correct path:
>This is not the Unix way to do things. The Unix API does not provide any way for a process to find out where its executable image is located (it might not exist anymore!) See:
It's also worth noting that the path returned is not incorrect for Cygwin.
It's the POSIX form of the path when the drive is unmounted in Cygwin.
Of course, this path is only recognized by Cygwin-enabled tools. For
those times in your code when you need to convert between POSIX and
Windows paths (and back), there are functions to do so:
cygwin_conv_to_win32_path(IN const char *posix_path, OUT char *win32_path);
cygwin_conv_to_posix_path(IN const char *win32_path, OUT char *posix_path);
The command line equivalent is 'cygpath'.
For those curious, all of this information is in the email list archives,
the Cygwin User's Guide, and/or the Cygwin API reference.
Larry Hall firstname.lastname@example.org
RFK Partners, Inc. http://www.rfk.com
838 Washington Street (508) 893-9779 - RFK Office
Holliston, MA 01746 (508) 893-9889 - FAX
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html