Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 , Francis Harvey From: "Larry Hall (RFK Partners, Inc)" Subject: Re: GCC and getcwd Cc: "'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 Content-Type: text/plain; charset="us-ascii" 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/