SQLite

Check-in [6f8952a836]
Login

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

Overview
Comment:simplify os2FullPathname() and at the same time make the allocations more robust (CVS 4647)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6f8952a8366065c9baa48cacc9c36743788210db
User & Date: pweilbacher 2007-12-30 23:35:15.000
Context
2007-12-30
23:38
fix case in os2GetTempname() where none of the usual environment variables are set to not overwrite two unrelated bytes (CVS 4648) (check-in: 9719a06394 user: pweilbacher tags: trunk)
23:35
simplify os2FullPathname() and at the same time make the allocations more robust (CVS 4647) (check-in: 6f8952a836 user: pweilbacher tags: trunk)
23:29
move variable declaration to be able to compile sqlite3_mutex_alloc() with older compilers (like EMX/gcc 2.8.1) (CVS 4646) (check-in: a568a9cf37 user: pweilbacher tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_os2.c.
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804

805
806
807
808
809
810
811
812
813
814
static int os2FullPathname(
  sqlite3_vfs *pVfs,          /* Pointer to vfs object */
  const char *zRelative,      /* Possibly relative input path */
  int nFull,                  /* Size of output buffer in bytes */
  char *zFull                 /* Output buffer */
){
  if( strchr(zRelative, ':') ){
    sqlite3SetString( &zFull, zRelative, (char*)0 );
  }else{
    ULONG ulDriveNum = 0;
    ULONG ulDriveMap = 0;
    ULONG cbzBufLen = SQLITE_TEMPNAME_SIZE;
    char zDrive[2];
    char *zBuff = (char*)malloc( cbzBufLen );
    if( zBuff == 0 ){
      return SQLITE_NOMEM;
    }
    DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
    if( DosQueryCurrentDir( ulDriveNum, (PBYTE)zBuff, &cbzBufLen ) == NO_ERROR ){

      sprintf( zDrive, "%c", (char)('A' + ulDriveNum - 1) );
      sqlite3SetString( &zFull, zDrive, ":\\", zBuff,
                        "\\", zRelative, (char*)0 );
    }
    free( zBuff );
  }
  return SQLITE_OK;
}

#ifndef SQLITE_OMIT_LOAD_EXTENSION







|




<






>
|
<
<







786
787
788
789
790
791
792
793
794
795
796
797

798
799
800
801
802
803
804
805


806
807
808
809
810
811
812
static int os2FullPathname(
  sqlite3_vfs *pVfs,          /* Pointer to vfs object */
  const char *zRelative,      /* Possibly relative input path */
  int nFull,                  /* Size of output buffer in bytes */
  char *zFull                 /* Output buffer */
){
  if( strchr(zRelative, ':') ){
    sqlite3_snprintf( nFull, zFull, "%s", zRelative );
  }else{
    ULONG ulDriveNum = 0;
    ULONG ulDriveMap = 0;
    ULONG cbzBufLen = SQLITE_TEMPNAME_SIZE;

    char *zBuff = (char*)malloc( cbzBufLen );
    if( zBuff == 0 ){
      return SQLITE_NOMEM;
    }
    DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
    if( DosQueryCurrentDir( ulDriveNum, (PBYTE)zBuff, &cbzBufLen ) == NO_ERROR ){
      sqlite3_snprintf( nFull, zFull, "%c:\\%s\\%s",
                               (char)('A' + ulDriveNum - 1), zBuff, zRelative);


    }
    free( zBuff );
  }
  return SQLITE_OK;
}

#ifndef SQLITE_OMIT_LOAD_EXTENSION