/ Check-in [8a233845]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix os2GetTempname() to actually work: DosScanEnv() wants an empty PSZ as argument and we obviously don't need to test for file existence any more. (CVS 4512)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8a233845f61080cca24da3672444f3e5b985da67
User & Date: pweilbacher 2007-10-24 23:03:26
Context
2007-10-24
23:04
Fix os2CurrentTime() to give correct results for negative timezones. (CVS 4513) check-in: a3b82548 user: pweilbacher tags: trunk
23:03
Fix os2GetTempname() to actually work: DosScanEnv() wants an empty PSZ as argument and we obviously don't need to test for file existence any more. (CVS 4512) check-in: 8a233845 user: pweilbacher tags: trunk
21:52
fts3.c buildTerms() passes -1 for nInput. (CVS 4511) check-in: e87c883a user: shess tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_os2.c.

743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775


776
777
778
779
780
781
782
*/
static int os2GetTempname( sqlite3_vfs *pVfs, int nBuf, char *zBuf ){
  static const unsigned char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "0123456789";
  int i, j;
  char zTempPath[CCHMAXPATH];
  APIRET rc = NO_ERROR;
  FILESTATUS3 fsts3ConfigInfo;
  if( DosScanEnv( (PSZ)"TEMP", (PSZ*)&zTempPath ) ){
    if( DosScanEnv( (PSZ)"TMP", (PSZ*)&zTempPath ) ){
      if( DosScanEnv( (PSZ)"TMPDIR", (PSZ*)&zTempPath ) ){
           ULONG ulDriveNum = 0, ulDriveMap = 0;
           DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
           sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
      }
    }
  }
  do{
    assert( nBuf>=pVfs->mxPathname );
    sqlite3_snprintf(pVfs->mxPathname-17, zBuf, "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath );
    j = strlen( zBuf );
    sqlite3Randomness( 15, &zBuf[j] );
    for( i = 0; i < 15; i++, j++ ){
      zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
    }
    zBuf[j] = 0;

    memset(&fsts3ConfigInfo, 0, sizeof(fsts3ConfigInfo));
    rc = DosQueryPathInfo( (PSZ)zBuf, FIL_STANDARD,
                           &fsts3ConfigInfo, sizeof(FILESTATUS3) );
  }while( rc != NO_ERROR );


  OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
  return SQLITE_OK;
}


/*
** Turn a relative pathname into a full pathname.  Write the full







|
<
<
|
|
|






|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>







743
744
745
746
747
748
749
750


751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
*/
static int os2GetTempname( sqlite3_vfs *pVfs, int nBuf, char *zBuf ){
  static const unsigned char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "0123456789";
  int i, j;
  PSZ zTempPath = "";


  if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){
    if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){
      if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){
           ULONG ulDriveNum = 0, ulDriveMap = 0;
           DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
           sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
      }
    }
  }
  /* strip off a trailing slashes or backslashes, otherwise we would get *
   * multiple (back)slashes which causes DosOpen() to fail               */
  j = strlen(zTempPath);
  while( j > 0 && ( zTempPath[j-1] == '\\' || zTempPath[j-1] == '/' ) ){
    j--;
  }
  zTempPath[j] = '\0';
  assert( nBuf>=pVfs->mxPathname );
  sqlite3_snprintf( pVfs->mxPathname-30, zBuf,
                    "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath );
  j = strlen( zBuf );
  sqlite3Randomness( 20, &zBuf[j] );
  for( i = 0; i < 20; i++, j++ ){
    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
  }
  zBuf[j] = 0;
  OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
  return SQLITE_OK;
}


/*
** Turn a relative pathname into a full pathname.  Write the full