cygwin_conv_path sometimes removes trailing slash

Ken Brown kbrown@cornell.edu
Sat Jan 30 20:46:00 GMT 2016


I'm using cygwin_conv_path to convert Win32 paths to POSIX paths, and 
I'm puzzled by the conversion

   d:/ --> /cygdrive/d

without the trailing slash.  By contrast, we have

   d:/foo/ --> /cygdrive/d/foo/

Is the removal of the trailing slash in the first example a deliberate 
design decision?  I find it counter-intuitive.

My tests are essentially based on the example at the end of 
https://cygwin.com/cygwin-api/func-cygwin-conv-path.html:

#include <sys/cygwin.h>
#include <stdio.h>
#include <stdlib.h>

int
main ()
{
   wchar_t *win32 = L"d:/";
   ssize_t size;
   char *posix;
   size = cygwin_conv_path (CCP_WIN_W_TO_POSIX, win32, NULL, 0);
   if (size < 0)
     perror ("cygwin_conv_path");
   else
     {
       posix = (char *) malloc (size);
       if (cygwin_conv_path (CCP_WIN_W_TO_POSIX, win32, posix, size))
	perror ("cygwin_conv_path");
     }
   printf ("%s\n", posix);
}

Ken

--
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



More information about the Cygwin mailing list