delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/01/31/18:12:43

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <4.3.1.2.20020131175754.02150450@pop.ma.ultranet.com>
X-Sender: lhall AT pop DOT ma DOT ultranet DOT com
X-Mailer: QUALCOMM Windows Eudora Version 4.3.1
Date: Thu, 31 Jan 2002 18:08:33 -0500
To: Sami Tikka <sami DOT tikka AT welho DOT com>, Francis Harvey <HARVEYF1 AT WESTAT DOT com>
From: "Larry Hall (RFK Partners, Inc)" <lhall AT rfk DOT com>
Subject: Re: GCC and getcwd
Cc: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
In-Reply-To: <3C59CB7A.6000202@welho.com>
References: <08B08C9FA5EBD311A2CC009027D5BF81032B0F9E AT remailnt2-re01 DOT westat DOT com>
Mime-Version: 1.0

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:
>http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC23



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                              lhall AT rfk DOT com
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
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019