Fossil SCM
Fix temporary directory separator handling for Cygwin. For testing purposes. (Change taken over from SQLite's "cygDirSep" branch)
Commit
7bba46776ccd226444f221177abe9e333d83fd53
Parent
6dd4d75e1508d5c…
1 file changed
+31
-22
+31
-22
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -30936,18 +30936,14 @@ | ||
| 30936 | 30936 | #ifndef UNUSED_VARIABLE_VALUE |
| 30937 | 30937 | # define UNUSED_VARIABLE_VALUE(x) (void)(x) |
| 30938 | 30938 | #endif |
| 30939 | 30939 | |
| 30940 | 30940 | /* |
| 30941 | -** Returns the string that should be used as the directory separator. | |
| 30941 | +** Returns the character that should be used as the directory separator. | |
| 30942 | 30942 | */ |
| 30943 | -#ifndef winGetDirDep | |
| 30944 | -# ifdef __CYGWIN__ | |
| 30945 | -# define winGetDirDep() "/" | |
| 30946 | -# else | |
| 30947 | -# define winGetDirDep() "\\" | |
| 30948 | -# endif | |
| 30943 | +#ifndef winGetDirSep | |
| 30944 | +# define winGetDirSep() '\\' | |
| 30949 | 30945 | #endif |
| 30950 | 30946 | |
| 30951 | 30947 | /* |
| 30952 | 30948 | ** Do we need to manually define the Win32 file mapping APIs for use with WAL |
| 30953 | 30949 | ** mode (e.g. these APIs are available in the Windows CE SDK; however, they |
| @@ -34809,16 +34805,25 @@ | ||
| 34809 | 34805 | return zConverted; |
| 34810 | 34806 | } |
| 34811 | 34807 | |
| 34812 | 34808 | /* |
| 34813 | 34809 | ** This function returns non-zero if the specified UTF-8 string buffer |
| 34814 | -** ends with a directory separator character. | |
| 34810 | +** ends with a directory separator character or one was successfully | |
| 34811 | +** added to it. | |
| 34815 | 34812 | */ |
| 34816 | -static int winEndsInDirSep(char *zBuf){ | |
| 34813 | +static int winMakeEndInDirSep(int nBuf, char *zBuf){ | |
| 34817 | 34814 | if( zBuf ){ |
| 34818 | 34815 | int nLen = sqlite3Strlen30(zBuf); |
| 34819 | - return nLen>0 && winIsDirSep(zBuf[nLen-1]); | |
| 34816 | + if( nLen>0 ){ | |
| 34817 | + if( winIsDirSep(zBuf[nLen-1]) ){ | |
| 34818 | + return 1; | |
| 34819 | + }else if( nLen+1<nBuf ){ | |
| 34820 | + zBuf[nLen] = winGetDirSep(); | |
| 34821 | + zBuf[nLen+1] = '\0'; | |
| 34822 | + return 1; | |
| 34823 | + } | |
| 34824 | + } | |
| 34820 | 34825 | } |
| 34821 | 34826 | return 0; |
| 34822 | 34827 | } |
| 34823 | 34828 | |
| 34824 | 34829 | /* |
| @@ -34842,11 +34847,11 @@ | ||
| 34842 | 34847 | |
| 34843 | 34848 | /* Allocate a temporary buffer to store the fully qualified file |
| 34844 | 34849 | ** name for the temporary file. If this fails, we cannot continue. |
| 34845 | 34850 | */ |
| 34846 | 34851 | nBuf = pVfs->mxPathname; |
| 34847 | - zBuf = sqlite3MallocZero( nBuf+2 ); | |
| 34852 | + zBuf = sqlite3MallocZero( nBuf+3 ); | |
| 34848 | 34853 | if( !zBuf ){ |
| 34849 | 34854 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34850 | 34855 | return SQLITE_IOERR_NOMEM; |
| 34851 | 34856 | } |
| 34852 | 34857 | |
| @@ -34854,13 +34859,12 @@ | ||
| 34854 | 34859 | ** has been explicitly set by the application; otherwise, use the one |
| 34855 | 34860 | ** configured by the operating system. |
| 34856 | 34861 | */ |
| 34857 | 34862 | assert( nBuf>30 ); |
| 34858 | 34863 | if( sqlite3_temp_directory ){ |
| 34859 | - sqlite3_snprintf(nBuf-30, zBuf, "%s%s", sqlite3_temp_directory, | |
| 34860 | - winEndsInDirSep(sqlite3_temp_directory) ? "" : | |
| 34861 | - winGetDirDep()); | |
| 34864 | + sqlite3_snprintf(nBuf-30, zBuf, "%s", sqlite3_temp_directory); | |
| 34865 | + winMakeEndInDirSep(nBuf-30, zBuf); | |
| 34862 | 34866 | } |
| 34863 | 34867 | #if defined(__CYGWIN__) |
| 34864 | 34868 | else{ |
| 34865 | 34869 | static const char *azDirs[] = { |
| 34866 | 34870 | 0, /* getenv("SQLITE_TMPDIR") */ |
| @@ -34885,12 +34889,12 @@ | ||
| 34885 | 34889 | for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){ |
| 34886 | 34890 | void *zConverted; |
| 34887 | 34891 | if( zDir==0 ) continue; |
| 34888 | 34892 | /* If the path starts with a drive letter followed by the colon |
| 34889 | 34893 | ** character, assume it is already a native Win32 path; otherwise, |
| 34890 | - ** it must be converted to a native Win32 path prior via the Cygwin | |
| 34891 | - ** API prior to using it. | |
| 34894 | + ** it must be converted to a native Win32 path via the Cygwin API | |
| 34895 | + ** prior to using it. | |
| 34892 | 34896 | */ |
| 34893 | 34897 | if( winIsDriveLetterAndColon(zDir) ){ |
| 34894 | 34898 | zConverted = winConvertFromUtf8Filename(zDir); |
| 34895 | 34899 | if( !zConverted ){ |
| 34896 | 34900 | sqlite3_free(zBuf); |
| @@ -34897,10 +34901,11 @@ | ||
| 34897 | 34901 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34898 | 34902 | return SQLITE_IOERR_NOMEM; |
| 34899 | 34903 | } |
| 34900 | 34904 | if( winIsDir(zConverted) ){ |
| 34901 | 34905 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir); |
| 34906 | + winMakeEndInDirSep(nBuf-30, zBuf); | |
| 34902 | 34907 | sqlite3_free(zConverted); |
| 34903 | 34908 | break; |
| 34904 | 34909 | } |
| 34905 | 34910 | sqlite3_free(zConverted); |
| 34906 | 34911 | }else{ |
| @@ -34931,15 +34936,17 @@ | ||
| 34931 | 34936 | sqlite3_free(zBuf); |
| 34932 | 34937 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34933 | 34938 | return SQLITE_IOERR_NOMEM; |
| 34934 | 34939 | } |
| 34935 | 34940 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); |
| 34941 | + winMakeEndInDirSep(nBuf-30, zBuf); | |
| 34936 | 34942 | sqlite3_free(zUtf8); |
| 34937 | 34943 | sqlite3_free(zConverted); |
| 34938 | 34944 | break; |
| 34939 | 34945 | }else{ |
| 34940 | 34946 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zConverted); |
| 34947 | + winMakeEndInDirSep(nBuf-30, zBuf); | |
| 34941 | 34948 | sqlite3_free(zConverted); |
| 34942 | 34949 | break; |
| 34943 | 34950 | } |
| 34944 | 34951 | } |
| 34945 | 34952 | sqlite3_free(zConverted); |
| @@ -34963,10 +34970,11 @@ | ||
| 34963 | 34970 | "winGetTempname1", 0); |
| 34964 | 34971 | } |
| 34965 | 34972 | zMulti = winUnicodeToUtf8(zWidePath); |
| 34966 | 34973 | if( zMulti ){ |
| 34967 | 34974 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti); |
| 34975 | + winMakeEndInDirSep(nBuf-30, zBuf); | |
| 34968 | 34976 | sqlite3_free(zMulti); |
| 34969 | 34977 | sqlite3_free(zWidePath); |
| 34970 | 34978 | }else{ |
| 34971 | 34979 | sqlite3_free(zWidePath); |
| 34972 | 34980 | sqlite3_free(zBuf); |
| @@ -34990,10 +34998,11 @@ | ||
| 34990 | 34998 | "winGetTempname2", 0); |
| 34991 | 34999 | } |
| 34992 | 35000 | zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); |
| 34993 | 35001 | if( zUtf8 ){ |
| 34994 | 35002 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); |
| 35003 | + winMakeEndInDirSep(nBuf-30, zBuf); | |
| 34995 | 35004 | sqlite3_free(zUtf8); |
| 34996 | 35005 | }else{ |
| 34997 | 35006 | sqlite3_free(zBuf); |
| 34998 | 35007 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34999 | 35008 | return SQLITE_IOERR_NOMEM; |
| @@ -35611,12 +35620,12 @@ | ||
| 35611 | 35620 | pVfs->mxPathname+1)<0 ){ |
| 35612 | 35621 | sqlite3_free(zOut); |
| 35613 | 35622 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35614 | 35623 | "winFullPathname1", zRelative); |
| 35615 | 35624 | } |
| 35616 | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", | |
| 35617 | - sqlite3_data_directory, winGetDirDep(), zOut); | |
| 35625 | + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", | |
| 35626 | + sqlite3_data_directory, winGetDirSep(), zOut); | |
| 35618 | 35627 | sqlite3_free(zOut); |
| 35619 | 35628 | }else{ |
| 35620 | 35629 | if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ |
| 35621 | 35630 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35622 | 35631 | "winFullPathname2", zRelative); |
| @@ -35634,12 +35643,12 @@ | ||
| 35634 | 35643 | ** NOTE: We are dealing with a relative path name and the data |
| 35635 | 35644 | ** directory has been set. Therefore, use it as the basis |
| 35636 | 35645 | ** for converting the relative path name to an absolute |
| 35637 | 35646 | ** one by prepending the data directory and a backslash. |
| 35638 | 35647 | */ |
| 35639 | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", | |
| 35640 | - sqlite3_data_directory, winGetDirDep(), zRelative); | |
| 35648 | + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", | |
| 35649 | + sqlite3_data_directory, winGetDirSep(), zRelative); | |
| 35641 | 35650 | }else{ |
| 35642 | 35651 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); |
| 35643 | 35652 | } |
| 35644 | 35653 | return SQLITE_OK; |
| 35645 | 35654 | #endif |
| @@ -35667,12 +35676,12 @@ | ||
| 35667 | 35676 | ** NOTE: We are dealing with a relative path name and the data |
| 35668 | 35677 | ** directory has been set. Therefore, use it as the basis |
| 35669 | 35678 | ** for converting the relative path name to an absolute |
| 35670 | 35679 | ** one by prepending the data directory and a backslash. |
| 35671 | 35680 | */ |
| 35672 | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", | |
| 35673 | - sqlite3_data_directory, winGetDirDep(), zRelative); | |
| 35681 | + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", | |
| 35682 | + sqlite3_data_directory, winGetDirSep(), zRelative); | |
| 35674 | 35683 | return SQLITE_OK; |
| 35675 | 35684 | } |
| 35676 | 35685 | zConverted = winConvertFromUtf8Filename(zRelative); |
| 35677 | 35686 | if( zConverted==0 ){ |
| 35678 | 35687 | return SQLITE_IOERR_NOMEM; |
| 35679 | 35688 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -30936,18 +30936,14 @@ | |
| 30936 | #ifndef UNUSED_VARIABLE_VALUE |
| 30937 | # define UNUSED_VARIABLE_VALUE(x) (void)(x) |
| 30938 | #endif |
| 30939 | |
| 30940 | /* |
| 30941 | ** Returns the string that should be used as the directory separator. |
| 30942 | */ |
| 30943 | #ifndef winGetDirDep |
| 30944 | # ifdef __CYGWIN__ |
| 30945 | # define winGetDirDep() "/" |
| 30946 | # else |
| 30947 | # define winGetDirDep() "\\" |
| 30948 | # endif |
| 30949 | #endif |
| 30950 | |
| 30951 | /* |
| 30952 | ** Do we need to manually define the Win32 file mapping APIs for use with WAL |
| 30953 | ** mode (e.g. these APIs are available in the Windows CE SDK; however, they |
| @@ -34809,16 +34805,25 @@ | |
| 34809 | return zConverted; |
| 34810 | } |
| 34811 | |
| 34812 | /* |
| 34813 | ** This function returns non-zero if the specified UTF-8 string buffer |
| 34814 | ** ends with a directory separator character. |
| 34815 | */ |
| 34816 | static int winEndsInDirSep(char *zBuf){ |
| 34817 | if( zBuf ){ |
| 34818 | int nLen = sqlite3Strlen30(zBuf); |
| 34819 | return nLen>0 && winIsDirSep(zBuf[nLen-1]); |
| 34820 | } |
| 34821 | return 0; |
| 34822 | } |
| 34823 | |
| 34824 | /* |
| @@ -34842,11 +34847,11 @@ | |
| 34842 | |
| 34843 | /* Allocate a temporary buffer to store the fully qualified file |
| 34844 | ** name for the temporary file. If this fails, we cannot continue. |
| 34845 | */ |
| 34846 | nBuf = pVfs->mxPathname; |
| 34847 | zBuf = sqlite3MallocZero( nBuf+2 ); |
| 34848 | if( !zBuf ){ |
| 34849 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34850 | return SQLITE_IOERR_NOMEM; |
| 34851 | } |
| 34852 | |
| @@ -34854,13 +34859,12 @@ | |
| 34854 | ** has been explicitly set by the application; otherwise, use the one |
| 34855 | ** configured by the operating system. |
| 34856 | */ |
| 34857 | assert( nBuf>30 ); |
| 34858 | if( sqlite3_temp_directory ){ |
| 34859 | sqlite3_snprintf(nBuf-30, zBuf, "%s%s", sqlite3_temp_directory, |
| 34860 | winEndsInDirSep(sqlite3_temp_directory) ? "" : |
| 34861 | winGetDirDep()); |
| 34862 | } |
| 34863 | #if defined(__CYGWIN__) |
| 34864 | else{ |
| 34865 | static const char *azDirs[] = { |
| 34866 | 0, /* getenv("SQLITE_TMPDIR") */ |
| @@ -34885,12 +34889,12 @@ | |
| 34885 | for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){ |
| 34886 | void *zConverted; |
| 34887 | if( zDir==0 ) continue; |
| 34888 | /* If the path starts with a drive letter followed by the colon |
| 34889 | ** character, assume it is already a native Win32 path; otherwise, |
| 34890 | ** it must be converted to a native Win32 path prior via the Cygwin |
| 34891 | ** API prior to using it. |
| 34892 | */ |
| 34893 | if( winIsDriveLetterAndColon(zDir) ){ |
| 34894 | zConverted = winConvertFromUtf8Filename(zDir); |
| 34895 | if( !zConverted ){ |
| 34896 | sqlite3_free(zBuf); |
| @@ -34897,10 +34901,11 @@ | |
| 34897 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34898 | return SQLITE_IOERR_NOMEM; |
| 34899 | } |
| 34900 | if( winIsDir(zConverted) ){ |
| 34901 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir); |
| 34902 | sqlite3_free(zConverted); |
| 34903 | break; |
| 34904 | } |
| 34905 | sqlite3_free(zConverted); |
| 34906 | }else{ |
| @@ -34931,15 +34936,17 @@ | |
| 34931 | sqlite3_free(zBuf); |
| 34932 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34933 | return SQLITE_IOERR_NOMEM; |
| 34934 | } |
| 34935 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); |
| 34936 | sqlite3_free(zUtf8); |
| 34937 | sqlite3_free(zConverted); |
| 34938 | break; |
| 34939 | }else{ |
| 34940 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zConverted); |
| 34941 | sqlite3_free(zConverted); |
| 34942 | break; |
| 34943 | } |
| 34944 | } |
| 34945 | sqlite3_free(zConverted); |
| @@ -34963,10 +34970,11 @@ | |
| 34963 | "winGetTempname1", 0); |
| 34964 | } |
| 34965 | zMulti = winUnicodeToUtf8(zWidePath); |
| 34966 | if( zMulti ){ |
| 34967 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti); |
| 34968 | sqlite3_free(zMulti); |
| 34969 | sqlite3_free(zWidePath); |
| 34970 | }else{ |
| 34971 | sqlite3_free(zWidePath); |
| 34972 | sqlite3_free(zBuf); |
| @@ -34990,10 +34998,11 @@ | |
| 34990 | "winGetTempname2", 0); |
| 34991 | } |
| 34992 | zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); |
| 34993 | if( zUtf8 ){ |
| 34994 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); |
| 34995 | sqlite3_free(zUtf8); |
| 34996 | }else{ |
| 34997 | sqlite3_free(zBuf); |
| 34998 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34999 | return SQLITE_IOERR_NOMEM; |
| @@ -35611,12 +35620,12 @@ | |
| 35611 | pVfs->mxPathname+1)<0 ){ |
| 35612 | sqlite3_free(zOut); |
| 35613 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35614 | "winFullPathname1", zRelative); |
| 35615 | } |
| 35616 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", |
| 35617 | sqlite3_data_directory, winGetDirDep(), zOut); |
| 35618 | sqlite3_free(zOut); |
| 35619 | }else{ |
| 35620 | if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ |
| 35621 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35622 | "winFullPathname2", zRelative); |
| @@ -35634,12 +35643,12 @@ | |
| 35634 | ** NOTE: We are dealing with a relative path name and the data |
| 35635 | ** directory has been set. Therefore, use it as the basis |
| 35636 | ** for converting the relative path name to an absolute |
| 35637 | ** one by prepending the data directory and a backslash. |
| 35638 | */ |
| 35639 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", |
| 35640 | sqlite3_data_directory, winGetDirDep(), zRelative); |
| 35641 | }else{ |
| 35642 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); |
| 35643 | } |
| 35644 | return SQLITE_OK; |
| 35645 | #endif |
| @@ -35667,12 +35676,12 @@ | |
| 35667 | ** NOTE: We are dealing with a relative path name and the data |
| 35668 | ** directory has been set. Therefore, use it as the basis |
| 35669 | ** for converting the relative path name to an absolute |
| 35670 | ** one by prepending the data directory and a backslash. |
| 35671 | */ |
| 35672 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", |
| 35673 | sqlite3_data_directory, winGetDirDep(), zRelative); |
| 35674 | return SQLITE_OK; |
| 35675 | } |
| 35676 | zConverted = winConvertFromUtf8Filename(zRelative); |
| 35677 | if( zConverted==0 ){ |
| 35678 | return SQLITE_IOERR_NOMEM; |
| 35679 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -30936,18 +30936,14 @@ | |
| 30936 | #ifndef UNUSED_VARIABLE_VALUE |
| 30937 | # define UNUSED_VARIABLE_VALUE(x) (void)(x) |
| 30938 | #endif |
| 30939 | |
| 30940 | /* |
| 30941 | ** Returns the character that should be used as the directory separator. |
| 30942 | */ |
| 30943 | #ifndef winGetDirSep |
| 30944 | # define winGetDirSep() '\\' |
| 30945 | #endif |
| 30946 | |
| 30947 | /* |
| 30948 | ** Do we need to manually define the Win32 file mapping APIs for use with WAL |
| 30949 | ** mode (e.g. these APIs are available in the Windows CE SDK; however, they |
| @@ -34809,16 +34805,25 @@ | |
| 34805 | return zConverted; |
| 34806 | } |
| 34807 | |
| 34808 | /* |
| 34809 | ** This function returns non-zero if the specified UTF-8 string buffer |
| 34810 | ** ends with a directory separator character or one was successfully |
| 34811 | ** added to it. |
| 34812 | */ |
| 34813 | static int winMakeEndInDirSep(int nBuf, char *zBuf){ |
| 34814 | if( zBuf ){ |
| 34815 | int nLen = sqlite3Strlen30(zBuf); |
| 34816 | if( nLen>0 ){ |
| 34817 | if( winIsDirSep(zBuf[nLen-1]) ){ |
| 34818 | return 1; |
| 34819 | }else if( nLen+1<nBuf ){ |
| 34820 | zBuf[nLen] = winGetDirSep(); |
| 34821 | zBuf[nLen+1] = '\0'; |
| 34822 | return 1; |
| 34823 | } |
| 34824 | } |
| 34825 | } |
| 34826 | return 0; |
| 34827 | } |
| 34828 | |
| 34829 | /* |
| @@ -34842,11 +34847,11 @@ | |
| 34847 | |
| 34848 | /* Allocate a temporary buffer to store the fully qualified file |
| 34849 | ** name for the temporary file. If this fails, we cannot continue. |
| 34850 | */ |
| 34851 | nBuf = pVfs->mxPathname; |
| 34852 | zBuf = sqlite3MallocZero( nBuf+3 ); |
| 34853 | if( !zBuf ){ |
| 34854 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34855 | return SQLITE_IOERR_NOMEM; |
| 34856 | } |
| 34857 | |
| @@ -34854,13 +34859,12 @@ | |
| 34859 | ** has been explicitly set by the application; otherwise, use the one |
| 34860 | ** configured by the operating system. |
| 34861 | */ |
| 34862 | assert( nBuf>30 ); |
| 34863 | if( sqlite3_temp_directory ){ |
| 34864 | sqlite3_snprintf(nBuf-30, zBuf, "%s", sqlite3_temp_directory); |
| 34865 | winMakeEndInDirSep(nBuf-30, zBuf); |
| 34866 | } |
| 34867 | #if defined(__CYGWIN__) |
| 34868 | else{ |
| 34869 | static const char *azDirs[] = { |
| 34870 | 0, /* getenv("SQLITE_TMPDIR") */ |
| @@ -34885,12 +34889,12 @@ | |
| 34889 | for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){ |
| 34890 | void *zConverted; |
| 34891 | if( zDir==0 ) continue; |
| 34892 | /* If the path starts with a drive letter followed by the colon |
| 34893 | ** character, assume it is already a native Win32 path; otherwise, |
| 34894 | ** it must be converted to a native Win32 path via the Cygwin API |
| 34895 | ** prior to using it. |
| 34896 | */ |
| 34897 | if( winIsDriveLetterAndColon(zDir) ){ |
| 34898 | zConverted = winConvertFromUtf8Filename(zDir); |
| 34899 | if( !zConverted ){ |
| 34900 | sqlite3_free(zBuf); |
| @@ -34897,10 +34901,11 @@ | |
| 34901 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34902 | return SQLITE_IOERR_NOMEM; |
| 34903 | } |
| 34904 | if( winIsDir(zConverted) ){ |
| 34905 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir); |
| 34906 | winMakeEndInDirSep(nBuf-30, zBuf); |
| 34907 | sqlite3_free(zConverted); |
| 34908 | break; |
| 34909 | } |
| 34910 | sqlite3_free(zConverted); |
| 34911 | }else{ |
| @@ -34931,15 +34936,17 @@ | |
| 34936 | sqlite3_free(zBuf); |
| 34937 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34938 | return SQLITE_IOERR_NOMEM; |
| 34939 | } |
| 34940 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); |
| 34941 | winMakeEndInDirSep(nBuf-30, zBuf); |
| 34942 | sqlite3_free(zUtf8); |
| 34943 | sqlite3_free(zConverted); |
| 34944 | break; |
| 34945 | }else{ |
| 34946 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zConverted); |
| 34947 | winMakeEndInDirSep(nBuf-30, zBuf); |
| 34948 | sqlite3_free(zConverted); |
| 34949 | break; |
| 34950 | } |
| 34951 | } |
| 34952 | sqlite3_free(zConverted); |
| @@ -34963,10 +34970,11 @@ | |
| 34970 | "winGetTempname1", 0); |
| 34971 | } |
| 34972 | zMulti = winUnicodeToUtf8(zWidePath); |
| 34973 | if( zMulti ){ |
| 34974 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti); |
| 34975 | winMakeEndInDirSep(nBuf-30, zBuf); |
| 34976 | sqlite3_free(zMulti); |
| 34977 | sqlite3_free(zWidePath); |
| 34978 | }else{ |
| 34979 | sqlite3_free(zWidePath); |
| 34980 | sqlite3_free(zBuf); |
| @@ -34990,10 +34998,11 @@ | |
| 34998 | "winGetTempname2", 0); |
| 34999 | } |
| 35000 | zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); |
| 35001 | if( zUtf8 ){ |
| 35002 | sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); |
| 35003 | winMakeEndInDirSep(nBuf-30, zBuf); |
| 35004 | sqlite3_free(zUtf8); |
| 35005 | }else{ |
| 35006 | sqlite3_free(zBuf); |
| 35007 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 35008 | return SQLITE_IOERR_NOMEM; |
| @@ -35611,12 +35620,12 @@ | |
| 35620 | pVfs->mxPathname+1)<0 ){ |
| 35621 | sqlite3_free(zOut); |
| 35622 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35623 | "winFullPathname1", zRelative); |
| 35624 | } |
| 35625 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 35626 | sqlite3_data_directory, winGetDirSep(), zOut); |
| 35627 | sqlite3_free(zOut); |
| 35628 | }else{ |
| 35629 | if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ |
| 35630 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35631 | "winFullPathname2", zRelative); |
| @@ -35634,12 +35643,12 @@ | |
| 35643 | ** NOTE: We are dealing with a relative path name and the data |
| 35644 | ** directory has been set. Therefore, use it as the basis |
| 35645 | ** for converting the relative path name to an absolute |
| 35646 | ** one by prepending the data directory and a backslash. |
| 35647 | */ |
| 35648 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 35649 | sqlite3_data_directory, winGetDirSep(), zRelative); |
| 35650 | }else{ |
| 35651 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); |
| 35652 | } |
| 35653 | return SQLITE_OK; |
| 35654 | #endif |
| @@ -35667,12 +35676,12 @@ | |
| 35676 | ** NOTE: We are dealing with a relative path name and the data |
| 35677 | ** directory has been set. Therefore, use it as the basis |
| 35678 | ** for converting the relative path name to an absolute |
| 35679 | ** one by prepending the data directory and a backslash. |
| 35680 | */ |
| 35681 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 35682 | sqlite3_data_directory, winGetDirSep(), zRelative); |
| 35683 | return SQLITE_OK; |
| 35684 | } |
| 35685 | zConverted = winConvertFromUtf8Filename(zRelative); |
| 35686 | if( zConverted==0 ){ |
| 35687 | return SQLITE_IOERR_NOMEM; |
| 35688 |