persistentstorage/sql/OsLayer/os_symbian.cpp
branchRCL_3
changeset 16 6b6fd149daa2
parent 12 31a8f755b7fe
child 20 04ec7606545c
equal deleted inserted replaced
13:211563e4b919 16:6b6fd149daa2
    81 	EPanicInvalidSectorSize		=18,
    81 	EPanicInvalidSectorSize		=18,
    82 	EPanicInternalError			=19,
    82 	EPanicInternalError			=19,
    83 	EPanicNullDbFilePtr			=20,
    83 	EPanicNullDbFilePtr			=20,
    84 	EPanicFastCounterFreq		=21
    84 	EPanicFastCounterFreq		=21
    85 	};
    85 	};
       
    86 
       
    87 //Bit-mask constant. If xOpen()'s "aFlag" parameter contains one of these bits set, then the the file top be
       
    88 //opened or created is a journal file.
       
    89 const TUint KJournalFileTypeBitMask = SQLITE_OPEN_MAIN_JOURNAL | SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_MASTER_JOURNAL; 
    86 
    90 
    87 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    91 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    88 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    92 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    89 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    93 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    90 #ifdef _SQLPROFILER
    94 #ifdef _SQLPROFILER
  1216 	{
  1220 	{
  1217 	if(aFileName)
  1221 	if(aFileName)
  1218 		{
  1222 		{
  1219 		wchar_t* dest = reinterpret_cast <wchar_t*> (const_cast <TUint16*> (aFileNameDestBuf.Ptr()));
  1223 		wchar_t* dest = reinterpret_cast <wchar_t*> (const_cast <TUint16*> (aFileNameDestBuf.Ptr()));
  1220 		TInt len = mbstowcs(dest, aFileName, aFileNameDestBuf.MaxLength());
  1224 		TInt len = mbstowcs(dest, aFileName, aFileNameDestBuf.MaxLength());
       
  1225 		__ASSERT_DEBUG(len >= 0, User::Panic(KPanicCategory, EPanicInternalError));
  1221 		//If len == aFileNameDestBuf.MaxLength(), then the output buffer is too small.
  1226 		//If len == aFileNameDestBuf.MaxLength(), then the output buffer is too small.
  1222 		if(len > 0 && len < aFileNameDestBuf.MaxLength())
  1227 		if(len < aFileNameDestBuf.MaxLength())
  1223 			{
  1228 			{
  1224 			aFileNameDestBuf.SetLength(len);
  1229 			aFileNameDestBuf.SetLength(len);
  1225 			return ETrue;
  1230 			return ETrue;
  1226 			}
  1231 			}
  1227 		}
  1232 		}
  1244 static TBool ConvertFromUnicode(const TDesC& aFileName, TDes8& aFileNameDestBuf)
  1249 static TBool ConvertFromUnicode(const TDesC& aFileName, TDes8& aFileNameDestBuf)
  1245 	{
  1250 	{
  1246 	char* dest = reinterpret_cast <char*> (const_cast <TUint8*> (aFileNameDestBuf.Ptr()));
  1251 	char* dest = reinterpret_cast <char*> (const_cast <TUint8*> (aFileNameDestBuf.Ptr()));
  1247 	const wchar_t* src = reinterpret_cast <const wchar_t*> (aFileName.Ptr());
  1252 	const wchar_t* src = reinterpret_cast <const wchar_t*> (aFileName.Ptr());
  1248 	TInt len = wcstombs(dest, src, aFileNameDestBuf.MaxLength());
  1253 	TInt len = wcstombs(dest, src, aFileNameDestBuf.MaxLength());
       
  1254 	__ASSERT_DEBUG(len >= 0, User::Panic(KPanicCategory, EPanicInternalError));
  1249 	//If len == aFileNameDestBuf.MaxLength(), then the output buffer is too small.
  1255 	//If len == aFileNameDestBuf.MaxLength(), then the output buffer is too small.
  1250 	if(len > 0 && len < aFileNameDestBuf.MaxLength())
  1256 	if(len < aFileNameDestBuf.MaxLength())
  1251 		{
  1257 		{
  1252 		aFileNameDestBuf.SetLength(len);
  1258 		aFileNameDestBuf.SetLength(len);
  1253 		return ETrue;
  1259 		return ETrue;
  1254 		}
  1260 		}
  1255 	return EFalse;
  1261 	return EFalse;
  2003 		}
  2009 		}
  2004 	if(aDriveInfo.iDriveAtt & KDriveAttTransaction)
  2010 	if(aDriveInfo.iDriveAtt & KDriveAttTransaction)
  2005 		{
  2011 		{
  2006 		deviceCharacteristics |= SQLITE_IOCAP_ATOMIC;	
  2012 		deviceCharacteristics |= SQLITE_IOCAP_ATOMIC;	
  2007 		}
  2013 		}
  2008 	if(aVolumeInfo.iBlockSize >= SQLITE_DEFAULT_SECTOR_SIZE && (aVolumeInfo.iBlockSize & (aVolumeInfo.iBlockSize - 1)) == 0)	
  2014 	switch(aVolumeInfo.iBlockSize)
  2009 		{
  2015 		{
  2010 		switch(aVolumeInfo.iBlockSize)
  2016 		case 512:
  2011 			{
  2017 			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC512;
  2012 			case 512:
  2018 			break;
  2013 				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC512;
  2019 		case 1024:
  2014 				break;
  2020 			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC1K;
  2015 			case 1024:
  2021 			break;
  2016 				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC1K;
  2022 		case 2048:
  2017 				break;
  2023 			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC2K;
  2018 			case 2048:
  2024 			break;
  2019 				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC2K;
  2025 		case 4096:
  2020 				break;
  2026 			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC4K;
  2021 			case 4096:
  2027 			break;
  2022 				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC4K;
  2028 		case 8192:
  2023 				break;
  2029 			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC8K;
  2024 			case 8192:
  2030 			break;
  2025 				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC8K;
  2031 		case 16384:
  2026 				break;
  2032 			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC16K;
  2027 			case 16384:
  2033 			break;
  2028 				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC16K;
  2034 		case 32768:
  2029 				break;
  2035 			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC32K;
  2030 			case 32768:
  2036 			break;
  2031 				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC32K;
  2037 		case 65536:
  2032 				break;
  2038 			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC64K;
  2033 			case 65536:
  2039 			break;
  2034 				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC64K;
  2040 		default:
  2035 				break;
  2041 			//Do nothing. deviceCharacteristics was initialized with 0 at the beginning of the function body.
  2036 			default:
  2042 			break;
  2037 				//Do nothing. deviceCharacteristics was initialized with 0 at the beginning of the function body.
       
  2038 				break;
       
  2039 			}
       
  2040 		}
  2043 		}
  2041 	return deviceCharacteristics;
  2044 	return deviceCharacteristics;
  2042 	}
  2045 	}
  2043 
  2046 
  2044 /**
  2047 /**
  2285 			if(err != KErrNone && err != KErrNoMemory && err != KErrDiskFull)
  2288 			if(err != KErrNone && err != KErrNoMemory && err != KErrDiskFull)
  2286 				{
  2289 				{
  2287 				__FS_CALL(EFsOpFileOpen, 0);
  2290 				__FS_CALL(EFsOpFileOpen, 0);
  2288 				err = dbFile.iFileBuf.Open(osLayerData.iFs, fname, fmode);
  2291 				err = dbFile.iFileBuf.Open(osLayerData.iFs, fname, fmode);
  2289 				
  2292 				
  2290 				if(err == KErrNone && ((aFlags & SQLITE_OPEN_MAIN_JOURNAL) || (aFlags & SQLITE_OPEN_TEMP_JOURNAL) || 
  2293 				if(err == KErrNone && (aFlags & KJournalFileTypeBitMask))
  2291                         (aFlags & SQLITE_OPEN_SUBJOURNAL) || (aFlags & SQLITE_OPEN_MASTER_JOURNAL)))
       
  2292 				    {
  2294 				    {
  2293                     err = TVfs::DoFileSizeCorruptionCheck(dbFile, fname, fmode);
  2295                     err = TVfs::DoFileSizeCorruptionCheck(dbFile, fname, fmode);
  2294 				    }
  2296 				    }
  2295 				}
  2297 				}
  2296 			if((err != KErrNone && err != KErrNoMemory && err != KErrDiskFull) && (aFlags & SQLITE_OPEN_READWRITE))
  2298 			if((err != KErrNone && err != KErrNoMemory && err != KErrDiskFull) && (aFlags & SQLITE_OPEN_READWRITE))
  2336 			*aOutFlags = dbFile.iReadOnly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE;
  2338 			*aOutFlags = dbFile.iReadOnly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE;
  2337 			}
  2339 			}
  2338 		(void)dbFile.iFileBuf.SetReadAheadSize(dbFile.iSectorSize, recReadBufSize);
  2340 		(void)dbFile.iFileBuf.SetReadAheadSize(dbFile.iSectorSize, recReadBufSize);
  2339 		}
  2341 		}
  2340 #ifdef _SQLPROFILER
  2342 #ifdef _SQLPROFILER
  2341 	dbFile.iIsJournal = (aFlags & SQLITE_OPEN_MAIN_JOURNAL) || (aFlags & SQLITE_OPEN_TEMP_JOURNAL) || 
  2343 	dbFile.iIsJournal = aFlags & KJournalFileTypeBitMask; 
  2342 						(aFlags & SQLITE_OPEN_SUBJOURNAL) || (aFlags & SQLITE_OPEN_MASTER_JOURNAL);
       
  2343 #endif
  2344 #endif
  2344 	return err == KErrNone ? SQLITE_OK : (err == KErrNoMemory ? SQLITE_IOERR_NOMEM : SQLITE_CANTOPEN);
  2345 	return err == KErrNone ? SQLITE_OK : (err == KErrNoMemory ? SQLITE_IOERR_NOMEM : SQLITE_CANTOPEN);
  2345 	}
  2346 	}
  2346 
  2347 
  2347 /**
  2348 /**