This is the mail archive of the 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: GCC and getcwd

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                    
RFK Partners, Inc.            
838 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX

Unsubscribe info:
Bug reporting:

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