SQLite

View Ticket
Login
Ticket Hash: 2fd50fa6656950e19826089cd1abf19c35c26409
Title: cygwin-1.7 issues: winFullPathname and tempname
Status: Closed Type: Feature_Request
Severity: Important Priority: Medium
Subsystem: VFS Resolution: Fixed
Last Modified: 2013-08-29 07:22:57
Version Found In: <= 3.6.17
Description:
I needed the attached patch for the new cygwin-1.7, where cygwin_conv_to_full_win32_path() is deprecated.

But I doubt that this patch is fully correct. winFullPathname is mainly used to get the driveletter to check for the disksize and will fail for subst'ed drives.

And I saw databases which were created at the cwd instead of the given path.

Maybe someone sees the obvious mistake.

2009-08-21 Reini Urban <rurbanb@x-ray.at>

* os_win32.c (winFullPathname): support cygwin-1.7, fails with subst'ed drives
diff -u sqlite-3.6.17/src/os_win.c.orig sqlite-3.6.17/src/os_win.c
--- sqlite-3.6.17/src/os_win.c.orig	2009-08-08 19:44:58.000000000 +0200
+++ sqlite-3.6.17/src/os_win.c	2009-08-21 09:07:33.906250000 +0200
@@ -48,6 +48,7 @@
 
 #ifdef __CYGWIN__
 # include <sys/cygwin.h>
+# include <cygwin/version.h>
 #endif
 
 /*
@@ -1525,9 +1526,34 @@
   
 #if defined(__CYGWIN__)
   UNUSED_PARAMETER(nFull);
+#if (CYGWIN_VERSION_API_MINOR >= 181)
+  int nByte;
+  char *zOut;
+  WCHAR *zConverted;
+  nByte = nFull + 260 + 1001; /* from the cygwin sources */
+  zConverted = malloc( nByte*sizeof(zConverted[0]) );
+  if( zConverted==0 ){
+    return SQLITE_NOMEM;
+  }
+  cygwin_conv_path(CCP_POSIX_TO_WIN_W, zRelative, zConverted, nByte*sizeof(zConverted[0]));
+#if 0
+  printf("%s => %ls => %ls\n", zRelative, zConverted, &zConverted[4]);
+#endif
+  /* 4th: "\\?\D:..." => "D:..." */
+  zOut = unicodeToUtf8(&zConverted[4]);
+  free(zConverted);
+  if( zOut ){
+    sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zOut);
+    free(zOut);
+    return SQLITE_OK;
+  }else{
+    return SQLITE_NOMEM;
+  }
+#else
   cygwin_conv_to_full_win32_path(zRelative, zFull);
   return SQLITE_OK;
 #endif
+#endif
 
 #if SQLITE_OS_WINCE
   UNUSED_PARAMETER(nFull);

anonymous added on 2009-08-21 07:40:18:
sorry: wrong email correct is rurban@x-ray.at

also sent to http://cygwin.com/ml/cygwin/2009-08/msg00698.html


rogerb added on 2009-10-01 07:27:18:
See http://www.sqlite.org/cvstrac/tktview?tn=3937 which includes some more coding related to this issue.

User Comments:
mistachkin added on 2013-08-29 07:22:57:
Fixed by check-in [6b2838336a31e34c].