Index: src/os_win.c ================================================================== --- src/os_win.c +++ src/os_win.c @@ -115,18 +115,14 @@ #ifndef UNUSED_VARIABLE_VALUE # define UNUSED_VARIABLE_VALUE(x) (void)(x) #endif /* -** Returns the string that should be used as the directory separator. +** Returns the character that should be used as the directory separator. */ -#ifndef winGetDirDep -# ifdef __CYGWIN__ -# define winGetDirDep() "/" -# else -# define winGetDirDep() "\\" -# endif +#ifndef winGetDirSep +# define winGetDirSep() '\\' #endif /* ** Do we need to manually define the Win32 file mapping APIs for use with WAL ** mode (e.g. these APIs are available in the Windows CE SDK; however, they @@ -3988,16 +3984,25 @@ return zConverted; } /* ** This function returns non-zero if the specified UTF-8 string buffer -** ends with a directory separator character. +** ends with a directory separator character or one was successfully +** added to it. */ -static int winEndsInDirSep(char *zBuf){ +static int winMakeEndInDirSep(int nBuf, char *zBuf){ if( zBuf ){ int nLen = sqlite3Strlen30(zBuf); - return nLen>0 && winIsDirSep(zBuf[nLen-1]); + if( nLen>0 ){ + if( winIsDirSep(zBuf[nLen-1]) ){ + return 1; + }else if( nLen+1mxPathname; - zBuf = sqlite3MallocZero( nBuf+2 ); + zBuf = sqlite3MallocZero( nBuf+3 ); if( !zBuf ){ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); return SQLITE_IOERR_NOMEM; } @@ -4033,13 +4038,12 @@ ** has been explicitly set by the application; otherwise, use the one ** configured by the operating system. */ assert( nBuf>30 ); if( sqlite3_temp_directory ){ - sqlite3_snprintf(nBuf-30, zBuf, "%s%s", sqlite3_temp_directory, - winEndsInDirSep(sqlite3_temp_directory) ? "" : - winGetDirDep()); + sqlite3_snprintf(nBuf-30, zBuf, "%s", sqlite3_temp_directory); + winMakeEndInDirSep(nBuf-30, zBuf); } #if defined(__CYGWIN__) else{ static const char *azDirs[] = { 0, /* getenv("SQLITE_TMPDIR") */ @@ -4064,12 +4068,12 @@ for(i=0; imxPathname+1)<0 ){ sqlite3_free(zOut); return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname1", zRelative); } - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", - sqlite3_data_directory, winGetDirDep(), zOut); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", + sqlite3_data_directory, winGetDirSep(), zOut); sqlite3_free(zOut); }else{ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname2", zRelative); @@ -4813,12 +4822,12 @@ ** NOTE: We are dealing with a relative path name and the data ** directory has been set. Therefore, use it as the basis ** for converting the relative path name to an absolute ** one by prepending the data directory and a backslash. */ - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", - sqlite3_data_directory, winGetDirDep(), zRelative); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", + sqlite3_data_directory, winGetDirSep(), zRelative); }else{ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); } return SQLITE_OK; #endif @@ -4846,12 +4855,12 @@ ** NOTE: We are dealing with a relative path name and the data ** directory has been set. Therefore, use it as the basis ** for converting the relative path name to an absolute ** one by prepending the data directory and a backslash. */ - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", - sqlite3_data_directory, winGetDirDep(), zRelative); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", + sqlite3_data_directory, winGetDirSep(), zRelative); return SQLITE_OK; } zConverted = winConvertFromUtf8Filename(zRelative); if( zConverted==0 ){ return SQLITE_IOERR_NOMEM;