persistentstorage/sqlite3api/OsLayer/FileBuf64.cpp
branchRCL_3
changeset 23 26645d81f48d
parent 9 667e88a979d7
child 24 cc28652e0254
equal deleted inserted replaced
21:28839de615b4 23:26645d81f48d
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 #include "FileBuf64.h"
    15 #include "FileBuf64.h"
       
    16 #include "OstTraceDefinitions.h"
       
    17 #ifdef OST_TRACE_COMPILER_IN_USE
       
    18 #include "FileBuf64Traces.h"
       
    19 #endif
       
    20 #include "SqliteTraceDef.h"
    16 
    21 
    17 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    22 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    18 ///////////////////////////        PROFILER       ////////////////////////////////////////////////////////////////////
       
    19 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
    20 
       
    21 #ifdef _SQLPROFILER
       
    22 
       
    23 #define PROFILE_READ(pos,amount) \
       
    24 	do \
       
    25 		{ \
       
    26 		++iFileReadCount; iFileReadAmount += (amount); \
       
    27         RDebug::Print(_L(" -- FRead    this=%X, Cnt=%d, Pos=%ld, Amt=%d, Ttl=%ld\r\n"), (TUint32)this, iFileReadCount,  pos, amount, iFileReadAmount); \
       
    28 		} while(0)
       
    29 	
       
    30 #define PROFILE_WRITE(pos,amount) \
       
    31 	do \
       
    32 		{ \
       
    33 		++iFileWriteCount; iFileWriteAmount += (amount); \
       
    34 		RDebug::Print(_L(" -- FWrite   this=%X, Cnt=%d, Pos=%ld, Amt=%d, Ttl=%ld\r\n"), (TUint32)this, iFileWriteCount, pos, amount, iFileWriteAmount); \
       
    35 		} while(0)
       
    36 
       
    37 #define PROFILE_SIZE() \
       
    38 	do \
       
    39 		{ \
       
    40 		++iFileSizeCount; \
       
    41 		RDebug::Print(_L(" -- FSize    this=%X, Cnt=%d\r\n"), (TUint32)this, iFileSizeCount); \
       
    42 		} while(0)
       
    43 
       
    44 #define PROFILE_SETSIZE() \
       
    45 	do \
       
    46 		{ \
       
    47 		++iFileSetSizeCount; \
       
    48 		RDebug::Print(_L(" -- FSetSize this=%X, Cnt=%d\r\n"), (TUint32)this, iFileSetSizeCount); \
       
    49 		} while(0)
       
    50 
       
    51 #define PROFILE_FLUSH()	\
       
    52 	do \
       
    53 		{ \
       
    54 		++iFileFlushCount; \
       
    55 		RDebug::Print(_L(" -- FFlush   this=%X, Cnt=%d\r\n"), (TUint32)this, iFileFlushCount); \
       
    56 		} while(0)
       
    57 
       
    58 #else
       
    59 
       
    60 #define PROFILE_READ(pos,amount)	void(0)
       
    61 #define PROFILE_WRITE(pos,amount)	void(0)
       
    62 
       
    63 #define PROFILE_SIZE()			void(0)
       
    64 #define PROFILE_SETSIZE()		void(0)
       
    65 #define PROFILE_FLUSH()			void(0)
       
    66 
       
    67 #endif//_SQLPROFILER
       
    68 
    23 
    69 /**
    24 /**
    70 This constant is used for initializing the RFileBuf64::iFileSize data member and means that
    25 This constant is used for initializing the RFileBuf64::iFileSize data member and means that
    71 the iFileSize is not yet initialized with the real file size value. 
    26 the iFileSize is not yet initialized with the real file size value. 
    72 (RFileBuf64::iFileSize caches the file size value)
    27 (RFileBuf64::iFileSize caches the file size value)
    80 @internalComponent
    35 @internalComponent
    81 */
    36 */
    82 static const TInt KNextReadFilePosNotSet = -1;
    37 static const TInt KNextReadFilePosNotSet = -1;
    83 
    38 
    84 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    39 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    85 ///////////////////////////        ASSERTS & INVARIANT      //////////////////////////////////////////////////////////
    40 ///////////////////////////        FBUF INVARIANT      ///////////////////////////////////////////////////////////////
    86 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    41 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    87 
    42 
    88 #ifdef _DEBUG
    43 #ifdef _DEBUG
    89 
    44 
    90 #define __FILEBUF64_INVARIANT() Invariant()
    45 #define __FILEBUF64_INVARIANT() Invariant()
    91 
    46 
    92 /**
       
    93 String literal used in _DEBUG mode for indicating that the reported panic happened inside the RFileBuf64 implementation.
       
    94 
       
    95 @see TFileBufPanic64
       
    96 @internalComponent
       
    97 */
       
    98 _LIT(KPanicCategory, "FBuf64");
       
    99 
       
   100 /**
       
   101 Set of numeric constants used together with the KPanicCategory string literal in _DEBUG mode for providing more detailed
       
   102 information about the reason of the panic.
       
   103 
       
   104 @see KPanicCategory
       
   105 @internalComponent
       
   106 */
       
   107 enum TFileBufPanic64
       
   108 	{
       
   109 	EFBufPanicCapacity = 1,				//1
       
   110 	EFBufPanicNullBuf,
       
   111 	EFBufPanicBufLen,
       
   112 	EFBufPanicFilePos,
       
   113 	EFBufPanicFileSize,					//5
       
   114 	EFBufPanicFileHandle,
       
   115 	EFBufPanicFsHandle,
       
   116 	EFBufPanicMsgHandle,
       
   117 	EFBufPanicMsgIndex,
       
   118 	EFBufPanicFileNameLen,				//10
       
   119 	EFBufPanicNullThis,
       
   120 	EFBufPanicDirty,
       
   121 	EFBufPanicNextReadFilePos,
       
   122 	EFBufPanicNextReadFilePosHits,
       
   123 	EFBufPanicFileBlockSize,			//15
       
   124 	};
       
   125 
       
   126 /**
       
   127 Helper function used in the implementation of the __FBUF64_ASSERT() macro.
       
   128 In case if the expression in __FBUF64_ASSERT() macro evaluates to false, 
       
   129 PanicFileBuf64() will use the supplied aLine and aPanicCode arguments together with the KPanicCategory string literal
       
   130 to prepare and print out a line (including the time of the panic) to the default log. The calling thread will be panic'ed
       
   131 after that.
       
   132 
       
   133 @see TFileBufPanic64
       
   134 @see KPanicCategory
       
   135 @internalComponent
       
   136 */
       
   137 static void PanicFileBuf64(TInt aLine, TFileBufPanic64 aPanicCode)
       
   138 	{
       
   139 	TTime time;
       
   140 	time.HomeTime();
       
   141 	TDateTime dt = time.DateTime();
       
   142 	TBuf<16> tbuf;
       
   143 	tbuf.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond());
       
   144 	
       
   145 	TBuf<64> buf;
       
   146 	_LIT(KFormat,"**%S:RFileBuf64 panic %d, at line(%d)");
       
   147 	buf.Format(KFormat, &tbuf, aPanicCode, aLine);
       
   148 	RDebug::Print(buf);
       
   149 	User::Panic(KPanicCategory, aPanicCode);
       
   150 	}
       
   151 
       
   152 /**
       
   153 This macro should be used when there is a need to panic the client/server if "expr" condition is not satisfied.
       
   154 Works in only in debug mode. In release mode evaluates to nothing.
       
   155 
       
   156 @see TFileBufPanic64
       
   157 @see KPanicCategory
       
   158 @see PanicFileBuf64()
       
   159 @internalComponent
       
   160 */
       
   161 #define __FBUF64_ASSERT(expr, panicCode)	(void)(!(expr) ? ::PanicFileBuf64(__LINE__, panicCode) : void(0))
       
   162 
       
   163 #else //_DEBUG
    47 #else //_DEBUG
   164 
    48 
   165 #define __FILEBUF64_INVARIANT() void(0)
    49 #define __FILEBUF64_INVARIANT() void(0)
   166 
       
   167 #define __FBUF64_ASSERT(expr, panicCode) 	void(0)
       
   168 
    50 
   169 #endif//_DEBUG
    51 #endif//_DEBUG
   170 
    52 
   171 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    53 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   172 ///////////////////////////        RFileBuf64    /////////////////////////////////////////////////////////////////////
    54 ///////////////////////////        RFileBuf64    /////////////////////////////////////////////////////////////////////
   175 /**
    57 /**
   176 Initializes RFileBuf64 data members with their default values.
    58 Initializes RFileBuf64 data members with their default values.
   177 
    59 
   178 @param aSize Max file buffer size (capacity) in bytes.
    60 @param aSize Max file buffer size (capacity) in bytes.
   179 
    61 
   180 @panic FBuf64 1 In _DEBUG mode - aSize is 0 or negative.
    62 @panic Sqlite3 1 In _DEBUG mode - aSize is 0 or negative.
   181 */
    63 */
   182 RFileBuf64::RFileBuf64(TInt aSize) :
    64 RFileBuf64::RFileBuf64(TInt aSize) :
   183 	iCapacity(aSize),
    65 	iCapacity(aSize),
       
    66 	iBase(NULL),
   184 	iReadAheadSize(RFileBuf64::KDefaultReadAheadSize)
    67 	iReadAheadSize(RFileBuf64::KDefaultReadAheadSize)
   185 	{
    68 	{
   186 	__FBUF64_ASSERT(aSize > 0, EFBufPanicCapacity);
    69 	SQLITE_TRACE_FBUF(OstTraceExt3(TRACE_INTERNALS, RFILEBUF64_RFILEBUF64, "FBuf;0x%X;RFileBuf64::RFileBuf64;aSize=%d;iReadAheadSize=%d", (TUint)this, aSize, iReadAheadSize));
       
    70 	__ASSERT_DEBUG(aSize > 0, __SQLITEPANIC(EFBufPanicCapacity));
   187 	}
    71 	}
   188 
    72 
   189 /**
    73 /**
   190 Initializes the RFileBuf64 object and creates and opens a new file that will be accessed through RFileBuf64 public interface.
    74 Initializes the RFileBuf64 object and creates and opens a new file that will be accessed through RFileBuf64 public interface.
   191 If the file already exists, an error is returned.
    75 If the file already exists, an error is returned.
   200 @return KErrNone if successful, otherwise one of the other system-wide error codes.
    84 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   201 
    85 
   202 @see TFileMode
    86 @see TFileMode
   203 @see RFile64::Create()
    87 @see RFile64::Create()
   204 
    88 
   205 @panic FBuf64  7 In _DEBUG mode - Invalid aFs object (null file session handle).
    89 @panic Sqlite3  7 In _DEBUG mode - Invalid aFs object (null file session handle).
   206 @panic FBuf64 10 In _DEBUG mode - Invalid file name length (zero file name length).
    90 @panic Sqlite3 10 In _DEBUG mode - Invalid file name length (zero file name length).
   207 */
    91 */
   208 TInt RFileBuf64::Create(RFs& aFs, const TDesC& aFileName, TUint aFileMode)
    92 TInt RFileBuf64::Create(RFs& aFs, const TDesC& aFileName, TUint aFileMode)
   209 	{
    93 	{
   210 	__FBUF64_ASSERT(aFs.Handle() != 0, EFBufPanicFsHandle);
    94 	__ASSERT_DEBUG(aFs.Handle() != 0, __SQLITEPANIC(EFBufPanicFsHandle));
   211 	__FBUF64_ASSERT(aFileName.Length() > 0, EFBufPanicFileNameLen);
    95 	__ASSERT_DEBUG(aFileName.Length() > 0, __SQLITEPANIC(EFBufPanicFileNameLen));
   212 	
    96 	
   213     TInt err = DoPreInit();
    97 	TInt err = DoPreInit();
   214     if(err == KErrNone)
    98 	if(err == KErrNone)
   215         {
    99 	    {
   216         err = iFile.Create(aFs, aFileName, aFileMode);
   100 	    err = iFile.Create(aFs, aFileName, aFileMode);
   217         }
   101 	    }
   218     return DoPostInit(err);
   102 	SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_CREATE, "FBuf;0x%X;RFileBuf64::Create;aFs.Handle()=0x%X;aFileName=%S;iFile.SubSessionHandle()=0x%X;err=%d", (TUint)this, (TUint)aFs.Handle(), __SQLITEPRNSTR(aFileName), (TUint)iFile.SubSessionHandle(), err));
       
   103 	DoPostInit(err);
       
   104 	return err;
   219 	}
   105 	}
   220 
   106 
   221 /**
   107 /**
   222 Initializes the RFileBuf64 object and opens an existing file that will be accessed through RFileBuf64 public interface.
   108 Initializes the RFileBuf64 object and opens an existing file that will be accessed through RFileBuf64 public interface.
   223 If the file does not already exist, an error is returned.
   109 If the file does not already exist, an error is returned.
   231 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   117 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   232 
   118 
   233 @see TFileMode
   119 @see TFileMode
   234 @see RFile64::Open()
   120 @see RFile64::Open()
   235 
   121 
   236 @panic FBuf64  7 In _DEBUG mode - Invalid aFs object (null file session handle).
   122 @panic Sqlite3  7 In _DEBUG mode - Invalid aFs object (null file session handle).
   237 @panic FBuf64 10 In _DEBUG mode - Invalid file name length (zero file name length).
   123 @panic Sqlite3 10 In _DEBUG mode - Invalid file name length (zero file name length).
   238 */
   124 */
   239 TInt RFileBuf64::Open(RFs& aFs, const TDesC& aFileName, TUint aFileMode)
   125 TInt RFileBuf64::Open(RFs& aFs, const TDesC& aFileName, TUint aFileMode)
   240 	{
   126 	{
   241 	__FBUF64_ASSERT(aFs.Handle() != 0, EFBufPanicFsHandle);
   127 	__ASSERT_DEBUG(aFs.Handle() != 0, __SQLITEPANIC(EFBufPanicFsHandle));
   242 	__FBUF64_ASSERT(aFileName.Length() > 0, EFBufPanicFileNameLen);
   128 	__ASSERT_DEBUG(aFileName.Length() > 0, __SQLITEPANIC(EFBufPanicFileNameLen));
   243     
   129 	
   244     TInt err = DoPreInit();
   130     TInt err = DoPreInit();
   245     if(err == KErrNone)
   131     if(err == KErrNone)
   246         {
   132         {
   247         err = iFile.Open(aFs, aFileName, aFileMode);
   133         err = iFile.Open(aFs, aFileName, aFileMode);
   248         }
   134         }
   249     return DoPostInit(err);
   135 	SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_OPEN, "FBuf;0x%X;RFileBuf64::Open;aFs.Handle()=0x%X;aFileName=%S;iFile.SubSessionHandle()=0x%X;err=%d", (TUint)this, (TUint)aFs.Handle(), __SQLITEPRNSTR(aFileName), (TUint)iFile.SubSessionHandle(), err));
       
   136     DoPostInit(err);
       
   137 	return err;
   250 	}
   138 	}
   251 
   139 
   252 /**
   140 /**
   253 Initializes the RFileBuf64 object and creates and opens a temporary file with unique name that will be accessed through 
   141 Initializes the RFileBuf64 object and creates and opens a temporary file with unique name that will be accessed through 
   254 RFileBuf64 public interface.
   142 RFileBuf64 public interface.
   264 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   152 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   265 
   153 
   266 @see TFileMode
   154 @see TFileMode
   267 @see RFile64::Temp()
   155 @see RFile64::Temp()
   268 
   156 
   269 @panic FBuf64  7 In _DEBUG mode - Invalid aFs object (null file session handle).
   157 @panic Sqlite3  7 In _DEBUG mode - Invalid aFs object (null file session handle).
   270 */
   158 */
   271 TInt RFileBuf64::Temp(RFs& aFs, const TDesC& aPath, TFileName& aFileName, TUint aFileMode)
   159 TInt RFileBuf64::Temp(RFs& aFs, const TDesC& aPath, TFileName& aFileName, TUint aFileMode)
   272 	{
   160 	{
   273 	__FBUF64_ASSERT(aFs.Handle() != 0, EFBufPanicFsHandle);
   161 	__ASSERT_DEBUG(aFs.Handle() != 0, __SQLITEPANIC(EFBufPanicFsHandle));
   274     
   162 	
   275     TInt err = DoPreInit();
   163     TInt err = DoPreInit();
   276     if(err == KErrNone)
   164     if(err == KErrNone)
   277         {
   165         {
   278         err = iFile.Temp(aFs, aPath, aFileName, aFileMode);
   166         err = iFile.Temp(aFs, aPath, aFileName, aFileMode);
   279         }
   167         }
   280     return DoPostInit(err);
   168 	SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_TEMP, "FBuf;0x%X;RFileBuf64::Temp;aFs.Handle()=0x%X;aFileName=%S;iFile.SubSessionHandle()=0x%X;err=%d", (TUint)this, (TUint)aFs.Handle(), __SQLITEPRNSTR(aFileName), (TUint)iFile.SubSessionHandle(), err));
       
   169     DoPostInit(err);
       
   170 	return err;
   281 	}
   171 	}
   282 
   172 
   283 /**
   173 /**
   284 Writes to the file the pending data (if the buffer contains pending data), closes the file and releases
   174 Writes to the file the pending data (if the buffer contains pending data), closes the file and releases
   285 the RFileBuf64 resources. 
   175 the RFileBuf64 resources. 
   288 
   178 
   289 @see RFileBuf64::Flush()
   179 @see RFileBuf64::Flush()
   290 */
   180 */
   291 void RFileBuf64::Close()
   181 void RFileBuf64::Close()
   292 	{
   182 	{
       
   183 	SQLITE_TRACE_FBUF(OstTraceExt2(TRACE_INTERNALS, RFILEBUF64_CLOSE, "FBuf;0x%X;RFileBuf64::Close;iFile.SubSessionHandle()=0x%X", (TUint)this, (TUint)iFile.SubSessionHandle()));
   293 	if(iFile.SubSessionHandle() != 0 && iBase != 0)
   184 	if(iFile.SubSessionHandle() != 0 && iBase != 0)
   294 		{
   185 		{
   295 		(void)DoFileWrite2();
   186 		(void)DoFileWrite2();
   296 		}
   187 		}
   297 	iFile.Close();
   188 	iFile.Close();
   319 @see TVolumeIOParamInfo
   210 @see TVolumeIOParamInfo
   320 */
   211 */
   321 TInt RFileBuf64::SetReadAheadSize(TInt aBlockSize, TInt aReadRecBufSize)
   212 TInt RFileBuf64::SetReadAheadSize(TInt aBlockSize, TInt aReadRecBufSize)
   322 	{
   213 	{
   323 	__FILEBUF64_INVARIANT();
   214 	__FILEBUF64_INVARIANT();
   324 	if(aReadRecBufSize > 0 && (aReadRecBufSize & (aReadRecBufSize - 1)) == 0 && aReadRecBufSize > RFileBuf64::KDefaultReadAheadSize)
   215 	if((aReadRecBufSize & (aReadRecBufSize - 1)) == 0 && aReadRecBufSize > RFileBuf64::KDefaultReadAheadSize)
   325 		{
   216 		{
   326 		iReadAheadSize = aReadRecBufSize > iCapacity ? iCapacity : aReadRecBufSize;
   217 		iReadAheadSize = aReadRecBufSize > iCapacity ? iCapacity : aReadRecBufSize;
   327 		}
   218 		}
   328 	else if(aBlockSize > 0 && (aBlockSize & (aBlockSize - 1)) == 0 && aBlockSize > RFileBuf64::KDefaultReadAheadSize)
   219 	else if((aBlockSize & (aBlockSize - 1)) == 0 && aBlockSize > RFileBuf64::KDefaultReadAheadSize)
   329 		{
   220 		{
   330 		iReadAheadSize = aBlockSize > iCapacity ? iCapacity : aBlockSize;
   221 		iReadAheadSize = aBlockSize > iCapacity ? iCapacity : aBlockSize;
   331 		}
   222 		}
       
   223 	SQLITE_TRACE_FBUF(OstTraceExt4(TRACE_INTERNALS, RFILEBUF64_SETREADAHEADSIZE, "FBuf;0x%X;RFileBuf64::SetReadAheadSize;aBlockSize=%d;aReadRecBufSize=%d;iReadAheadSize=%d", (TUint)this, aBlockSize, aReadRecBufSize, iReadAheadSize));
   332 	__FILEBUF64_INVARIANT();
   224 	__FILEBUF64_INVARIANT();
   333 	return iReadAheadSize;
   225 	return iReadAheadSize;
   334 	}
   226 	}
   335 
   227 
   336 /**
   228 /**
   345             are overwritten. On return, its length is set to the number of
   237             are overwritten. On return, its length is set to the number of
   346             bytes read.
   238             bytes read.
   347             
   239             
   348 @return KErrNone if successful, otherwise one of the other system-wide error  codes.
   240 @return KErrNone if successful, otherwise one of the other system-wide error  codes.
   349 
   241 
   350 @panic FBuf64  4 In _DEBUG mode - negative aFilePos value.
   242 @panic Sqlite3  4 In _DEBUG mode - negative aFilePos value.
   351 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   243 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   352 
   244 
   353 @see RFileBuf64::Invariant()
   245 @see RFileBuf64::Invariant()
   354 */
   246 */
   355 TInt RFileBuf64::Read(TInt64 aFilePos, TDes8& aDes)
   247 TInt RFileBuf64::Read(TInt64 aFilePos, TDes8& aDes)
   356 	{
   248 	{
   357 	__FBUF64_ASSERT(aFilePos >= 0, EFBufPanicFilePos);
   249 	__ASSERT_DEBUG(aFilePos >= 0, __SQLITEPANIC(EFBufPanicFilePos));
   358 	__FILEBUF64_INVARIANT();
   250 	__FILEBUF64_INVARIANT();
   359 	aDes.SetLength(0);
   251 	aDes.SetLength(0);
   360 	//1. The output buffer max len is 0
   252 	//1. The output buffer max len is 0
   361 	if(aDes.MaxLength() == 0)
   253 	if(aDes.MaxLength() == 0)
   362 		{
   254 		{
   372 		}
   264 		}
   373 	//3. Too big "read" request - read directly from the file
   265 	//3. Too big "read" request - read directly from the file
   374 	TInt len = aDes.MaxLength();
   266 	TInt len = aDes.MaxLength();
   375 	if(len > iCapacity)
   267 	if(len > iCapacity)
   376 		{
   268 		{
   377 		if((aFilePos + len) > iFilePos && !(aFilePos >= (iFilePos + iLength)))
   269 		if((aFilePos + len) > iFilePos && aFilePos < (iFilePos + iLength))
   378 			{//Write the pending data if the iDirty flag is set, otherwise preserve the buffer content.
   270 			{//Write the pending data if the iDirty flag is set, otherwise preserve the buffer content.
   379 			err = DoFileWrite1(aFilePos);
   271 			err = DoFileWrite1(aFilePos);
   380 			}
   272 			}
   381 		if(err == KErrNone)
   273 		if(err == KErrNone)
   382 			{
   274 			{
   383 			err = iFile.Read(aFilePos, aDes);
   275 			err = iFile.Read(aFilePos, aDes);
   384 			PROFILE_READ(aFilePos, aDes.Size());
   276 			SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_READ1, "FBuf;0x%X;RFileBuf64::Read;TooBigRq;iFileSize=%lld;aFilePos=%lld;len=%d;err=%d", (TUint)this, iFileSize, aFilePos, len, err));
   385 			}
   277 			}
   386 		__FILEBUF64_INVARIANT();
   278 		__FILEBUF64_INVARIANT();
   387 		return err;
   279 		return err;
   388 		}
   280 		}
   389 	//4. The requested data size is smaller than the buffer capacity
   281 	//4. The requested data size is smaller than the buffer capacity
   410 			if(iNextReadFilePos != aFilePos)
   302 			if(iNextReadFilePos != aFilePos)
   411 				{//Guessed read ahead was wrong. Direct "file read" operation
   303 				{//Guessed read ahead was wrong. Direct "file read" operation
   412 				iNextReadFilePosHits = 0;
   304 				iNextReadFilePosHits = 0;
   413 				TPtr8 ptr2(outptr, len);
   305 				TPtr8 ptr2(outptr, len);
   414 				err = iFile.Read(aFilePos, ptr2);
   306 				err = iFile.Read(aFilePos, ptr2);
   415 				PROFILE_READ(aFilePos, ptr2.Size());
   307 				SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_READ2, "FBuf;0x%X;RFileBuf64::Read;Read;iFileSize=%lld;aFilePos=%lld;len=%d;err=%d", (TUint)this, iFileSize, aFilePos, len, err));
   416 				if(err == KErrNone)
   308 				if(err == KErrNone)
   417 					{
   309 					{
   418 					iNextReadFilePos = aFilePos + len;
   310 					iNextReadFilePos = aFilePos + len;
   419 					len -= ptr2.Length();
   311 					len -= ptr2.Length();
   420 					}
   312 					}
   434 				// if read-ahead doesn't cross block boundary do it all
   326 				// if read-ahead doesn't cross block boundary do it all
   435 				readahead = maxReadAhead;	
   327 				readahead = maxReadAhead;	
   436 				}
   328 				}
   437 			TPtr8 ptr(iBase, Min(iCapacity, (len + readahead)));
   329 			TPtr8 ptr(iBase, Min(iCapacity, (len + readahead)));
   438 			err = iFile.Read(aFilePos, ptr);
   330 			err = iFile.Read(aFilePos, ptr);
   439 			PROFILE_READ(aFilePos, ptr.Size());
   331 			SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_READ3, "FBuf;0x%X;RFileBuf64::Read;ReadAhead;iFileSize=%lld;aFilePos=%lld;len=%d;err=%d", (TUint)this, iFileSize, aFilePos, ptr.MaxLength(), err));
   440 			if(err == KErrNone)
   332 			if(err == KErrNone)
   441 				{
   333 				{
   442 				iFilePos = aFilePos;
   334 				iFilePos = aFilePos;
   443 				iLength = ptr.Length();	
   335 				iLength = ptr.Length();	
   444 				iNextReadFilePos = iFilePos + iLength;
   336 				iNextReadFilePos = iFilePos + iLength;
   470 @param aData The descriptor from which binary data is written. The function writes 
   362 @param aData The descriptor from which binary data is written. The function writes 
   471              the entire contents of aData to the file.
   363              the entire contents of aData to the file.
   472 
   364 
   473 @return KErrNone if successful, otherwise one of the other system-wide error  codes.
   365 @return KErrNone if successful, otherwise one of the other system-wide error  codes.
   474 
   366 
   475 @panic FBuf64  4 In _DEBUG mode - negative aFilePos value.
   367 @panic Sqlite3  4 In _DEBUG mode - negative aFilePos value.
   476 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   368 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   477 
   369 
   478 @see RFileBuf64::Invariant()
   370 @see RFileBuf64::Invariant()
   479 */
   371 */
   480 TInt RFileBuf64::Write(TInt64 aFilePos, const TDesC8& aData)
   372 TInt RFileBuf64::Write(TInt64 aFilePos, const TDesC8& aData)
   481 	{
   373 	{
   482 	__FBUF64_ASSERT(aFilePos >= 0, EFBufPanicFilePos);
   374 	__ASSERT_DEBUG(aFilePos >= 0, __SQLITEPANIC(EFBufPanicFilePos));
   483 	__FILEBUF64_INVARIANT();
   375 	__FILEBUF64_INVARIANT();
   484 	if(aData.Length() == 0)
   376 	if(aData.Length() == 0)
   485 		{
   377 		{
   486 		__FILEBUF64_INVARIANT();
   378 		__FILEBUF64_INVARIANT();
   487 		return KErrNone;	
   379 		return KErrNone;	
   606 
   498 
   607 @param aFileSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic.
   499 @param aFileSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic.
   608 
   500 
   609 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   501 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   610 
   502 
   611 @panic FBuf64  5 In _DEBUG mode - negative aFileSize value.
   503 @panic Sqlite3  5 In _DEBUG mode - negative aFileSize value.
   612 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   504 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   613 
   505 
   614 @see RFileBuf64::Invariant()
   506 @see RFileBuf64::Invariant()
   615 */
   507 */
   616 TInt RFileBuf64::SetSize(TInt64 aFileSize)
   508 TInt RFileBuf64::SetSize(TInt64 aFileSize)
   617 	{
   509 	{
   618 	__FBUF64_ASSERT(aFileSize >= 0, EFBufPanicFileSize);
   510 	__ASSERT_DEBUG(aFileSize >= 0, __SQLITEPANIC(EFBufPanicFileSize));
   619 	__FILEBUF64_INVARIANT();
   511 	__FILEBUF64_INVARIANT();
   620 	return DoSetFileSize(aFileSize);
   512 	return DoSetFileSize(aFileSize);
   621 	}
   513 	}
   622 
   514 
   623 /**
   515 /**
   632         codes.
   524         codes.
   633 */
   525 */
   634 TInt RFileBuf64::Lock(TInt64 aFilePos, TInt64 aLength) const
   526 TInt RFileBuf64::Lock(TInt64 aFilePos, TInt64 aLength) const
   635 	{
   527 	{
   636 	__FILEBUF64_INVARIANT();
   528 	__FILEBUF64_INVARIANT();
   637 	return iFile.Lock(aFilePos, aLength);
   529 	TInt err = iFile.Lock(aFilePos, aLength);
       
   530 	SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_LOCK, "FBuf;0x%X;RFileBuf64::Lock;iFileSize=%lld;aFilePos=%lld;aLength=%lld;err=%d", (TUint)this, iFileSize, aFilePos, aLength, err));
       
   531 	return err;
   638 	}
   532 	}
   639 	
   533 	
   640 /**
   534 /**
   641 Unlocks a region within the file as defined by a range of bytes.
   535 Unlocks a region within the file as defined by a range of bytes.
   642 
   536 
   648 @return KErrNone if successful, otherwise one of the other  system-wide error codes.
   542 @return KErrNone if successful, otherwise one of the other  system-wide error codes.
   649 */
   543 */
   650 TInt RFileBuf64::UnLock(TInt64 aFilePos, TInt64 aLength) const
   544 TInt RFileBuf64::UnLock(TInt64 aFilePos, TInt64 aLength) const
   651 	{
   545 	{
   652 	__FILEBUF64_INVARIANT();
   546 	__FILEBUF64_INVARIANT();
   653 	return iFile.UnLock(aFilePos, aLength);
   547 	TInt err = iFile.UnLock(aFilePos, aLength);
       
   548 	SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_UNLOCK, "FBuf;0x%X;RFileBuf64::UnLock;iFileSize=%lld;aFilePos=%lld;aLength=%lld;err=%d", (TUint)this, iFileSize, aFilePos, aLength, err));
       
   549 	return err;
   654 	}
   550 	}
   655 
   551 
   656 /**
   552 /**
   657 Writes the pending data and then flushes the file.
   553 Writes the pending data and then flushes the file.
   658 
   554 
   697 @see RFileBuf64::Invariant()
   593 @see RFileBuf64::Invariant()
   698 */
   594 */
   699 TInt RFileBuf64::Drive(TInt& aDriveNumber, TDriveInfo& aDriveInfo) const
   595 TInt RFileBuf64::Drive(TInt& aDriveNumber, TDriveInfo& aDriveInfo) const
   700 	{
   596 	{
   701 	__FILEBUF64_INVARIANT();
   597 	__FILEBUF64_INVARIANT();
   702 	return iFile.Drive(aDriveNumber, aDriveInfo);
   598 	TInt err = iFile.Drive(aDriveNumber, aDriveInfo);
       
   599 	SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_DRIVE, "FBuf;0x%X;RFileBuf64::Drive;aDriveNumber=%d;driveAtt=0x%X;mediaAtt=0x%X;err=%d", (TUint)this, aDriveNumber, (TUint)aDriveInfo.iDriveAtt, (TUint)aDriveInfo.iMediaAtt, err));
       
   600 	return err;
   703 	}
   601 	}
   704 
   602 
   705 /**
   603 /**
   706 Initializes RFileBuf64 data members with their initial values.   
   604 Initializes RFileBuf64 data members with their initial values.   
   707 Allocates memory for the file buffer. 
   605 Allocates memory for the file buffer. 
   718     }
   616     }
   719 
   617 
   720 /**
   618 /**
   721 Performs post-initialization of the RFileBuf64 object.   
   619 Performs post-initialization of the RFileBuf64 object.   
   722 If aInitErr is not KErrNone, then the buffer memory will be released.
   620 If aInitErr is not KErrNone, then the buffer memory will be released.
   723 The function returns the aInitErr value to the caller. 
       
   724 
   621 
   725 @param aInitErr The result of the performed before the call RFileBuf64 initialization.
   622 @param aInitErr The result of the performed before the call RFileBuf64 initialization.
   726  
   623 */
   727 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   624 void RFileBuf64::DoPostInit(TInt aInitErr)
   728 */
       
   729 TInt RFileBuf64::DoPostInit(TInt aInitErr)
       
   730     {
   625     {
   731     if(aInitErr != KErrNone)
   626     if(aInitErr != KErrNone)
   732         {
   627         {
   733         User::Free(iBase);
   628         User::Free(iBase);
   734         iBase = 0;
   629         iBase = 0;
   735         }
   630         }
   736     return aInitErr;
       
   737     }
   631     }
   738 
   632 
   739 /**
   633 /**
   740 Discards the content of the RFileBuf64 object returning it to the state as if it has just been created. 
   634 Discards the content of the RFileBuf64 object returning it to the state as if it has just been created. 
   741 */
   635 */
   766 	if(iFileSize != KFileSizeNotSet)
   660 	if(iFileSize != KFileSizeNotSet)
   767 		{
   661 		{
   768 		__FILEBUF64_INVARIANT();
   662 		__FILEBUF64_INVARIANT();
   769 		return KErrNone;
   663 		return KErrNone;
   770 		}
   664 		}
   771 	PROFILE_SIZE();
       
   772 	TInt err = iFile.Size(iFileSize);
   665 	TInt err = iFile.Size(iFileSize);
       
   666 	SQLITE_TRACE_FBUF(OstTraceExt3(TRACE_INTERNALS, RFILEBUF64_DOFILESIZE, "FBuf;0x%X;RFileBuf64::DoFileSize;iFileSize=%lld;err=%d", (TUint)this, iFileSize, err));
   773 	if(err != KErrNone)
   667 	if(err != KErrNone)
   774 		{
   668 		{
   775 		DoDiscard();
   669 		DoDiscard();
   776 		}
   670 		}
   777 	__FILEBUF64_INVARIANT();
   671 	__FILEBUF64_INVARIANT();
   785 
   679 
   786 @param aFileSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic.
   680 @param aFileSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic.
   787 
   681 
   788 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   682 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   789 
   683 
   790 @panic FBuf64  5 In _DEBUG mode - negative aFileSize value.
   684 @panic Sqlite3  5 In _DEBUG mode - negative aFileSize value.
   791 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   685 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   792 
   686 
   793 @see RFileBuf64::Invariant()
   687 @see RFileBuf64::Invariant()
   794 */
   688 */
   795 TInt RFileBuf64::DoSetFileSize(TInt64 aFileSize)
   689 TInt RFileBuf64::DoSetFileSize(TInt64 aFileSize)
   796 	{
   690 	{
   797 	__FBUF64_ASSERT(aFileSize >= 0, EFBufPanicFileSize);
   691 	__ASSERT_DEBUG(aFileSize >= 0, __SQLITEPANIC(EFBufPanicFileSize));
   798 	__FILEBUF64_INVARIANT();
   692 	__FILEBUF64_INVARIANT();
   799 	if(aFileSize < iFilePos)
   693 	if(aFileSize < iFilePos)
   800 		{
   694 		{
   801 		iDirty = EFalse;
   695 		iDirty = EFalse;
   802 		iLength = 0;	
   696 		iLength = 0;	
   804 	//If the new file size is "in" the buffer then change the "iLength"
   698 	//If the new file size is "in" the buffer then change the "iLength"
   805 	else if(aFileSize < (iFilePos + iLength))
   699 	else if(aFileSize < (iFilePos + iLength))
   806 		{
   700 		{
   807 		iLength = aFileSize - iFilePos;
   701 		iLength = aFileSize - iFilePos;
   808 		}
   702 		}
   809 	PROFILE_SETSIZE();
       
   810 	TInt err = iFile.SetSize(aFileSize);
   703 	TInt err = iFile.SetSize(aFileSize);
       
   704 	SQLITE_TRACE_FBUF(OstTraceExt4(TRACE_INTERNALS, RFILEBUF64_DOSETFILESIZE, "FBuf;0x%X;RFileBuf64::DoSetFileSize;iFileSize=%lld;aFileSize=%lld;err=%d", (TUint)this, iFileSize, aFileSize, err));
   811 	if(err != KErrNone)
   705 	if(err != KErrNone)
   812 		{
   706 		{
   813 		DoDiscard();
   707 		DoDiscard();
   814 		}
   708 		}
   815 	else
   709 	else
   836 	if(err != KErrNone)
   730 	if(err != KErrNone)
   837 		{
   731 		{
   838 		__FILEBUF64_INVARIANT();
   732 		__FILEBUF64_INVARIANT();
   839 		return err;	
   733 		return err;	
   840 		}
   734 		}
   841 	PROFILE_FLUSH();
       
   842 	err = iFile.Flush();
   735 	err = iFile.Flush();
       
   736 	SQLITE_TRACE_FBUF(OstTraceExt3(TRACE_INTERNALS, RFILEBUF64_DOFILEFLUSH, "FBuf;0x%X;RFileBuf64::DoFileFlush;iFileSize=%lld;err=%d", (TUint)this, iFileSize, err));
   843 	if(err != KErrNone)
   737 	if(err != KErrNone)
   844 		{
   738 		{
   845 		DoDiscard();
   739 		DoDiscard();
   846 		}
   740 		}
   847 	iLength = 0;
   741 	iLength = 0;
   868 	if(iLength == 0)
   762 	if(iLength == 0)
   869 		{
   763 		{
   870 		__FILEBUF64_INVARIANT();
   764 		__FILEBUF64_INVARIANT();
   871 		return KErrNone;	
   765 		return KErrNone;	
   872 		}
   766 		}
   873 	PROFILE_WRITE(iFilePos, iLength);
       
   874 	TPtrC8 data(iBase, iLength);		
   767 	TPtrC8 data(iBase, iLength);		
   875 	TInt err = iFile.Write(iFilePos, data);
   768 	TInt err = iFile.Write(iFilePos, data);
       
   769 	SQLITE_TRACE_FBUF(OstTraceExt5(TRACE_INTERNALS, RFILEBUF64_DOFILEWRITE, "FBuf;0x%X;RFileBuf64::DoFileWrite;iFileSize=%lld;iFilePos=%lld;iLength=%d;err=%d", (TUint)this, iFileSize, iFilePos, iLength, err));
   876 	if(err == KErrNone)
   770 	if(err == KErrNone)
   877 		{
   771 		{
   878 		iFileSize = Max(iFileSize, (iFilePos + iLength));
   772 		iFileSize = Max(iFileSize, (iFilePos + iLength));
   879 		}
   773 		}
   880 	else
   774 	else
   900 
   794 
   901 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   795 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   902 
   796 
   903 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   797 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   904 				   
   798 				   
   905 @panic FBuf64  4 In _DEBUG mode - negative aNewFilePos value.
   799 @panic Sqlite3  4 In _DEBUG mode - negative aNewFilePos value.
   906 
   800 
   907 @see RFileBuf64::Read()
   801 @see RFileBuf64::Read()
   908 @see RFileBuf64::DoFileWrite()
   802 @see RFileBuf64::DoFileWrite()
   909 @see RFileBuf64::DoFileWrite2()
   803 @see RFileBuf64::DoFileWrite2()
   910 @see RFileBuf64::Invariant()
   804 @see RFileBuf64::Invariant()
   911 */
   805 */
   912 TInt RFileBuf64::DoFileWrite1(TInt64 aNewFilePos)
   806 TInt RFileBuf64::DoFileWrite1(TInt64 aNewFilePos)
   913 	{
   807 	{
   914 	__FBUF64_ASSERT(aNewFilePos >= 0, EFBufPanicFilePos);
   808 	__ASSERT_DEBUG(aNewFilePos >= 0, __SQLITEPANIC(EFBufPanicFilePos));
   915 	__FILEBUF64_INVARIANT();
   809 	__FILEBUF64_INVARIANT();
   916 	TInt err = KErrNone;
   810 	TInt err = KErrNone;
   917 	if(iDirty)
   811 	if(iDirty)
   918 		{
   812 		{
   919 		err = DoFileWrite();
   813 		err = DoFileWrite();
   947 
   841 
   948 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   842 @return KErrNone if successful, otherwise one of the other system-wide error codes.
   949 
   843 
   950 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   844 See RFileBuf64::Invariant() for other possible panics that may occur when this method is called.
   951 				   
   845 				   
   952 @panic FBuf64  4 In _DEBUG mode - negative aNewFilePos value.
   846 @panic Sqlite3  4 In _DEBUG mode - negative aNewFilePos value.
   953 
   847 
   954 @see RFileBuf64::Write()
   848 @see RFileBuf64::Write()
   955 @see RFileBuf64::DoFileWrite()
   849 @see RFileBuf64::DoFileWrite()
   956 @see RFileBuf64::DoFileWrite1()
   850 @see RFileBuf64::DoFileWrite1()
   957 @see RFileBuf64::Invariant()
   851 @see RFileBuf64::Invariant()
   958 */
   852 */
   959 TInt RFileBuf64::DoFileWrite2(TInt64 aNewFilePos)
   853 TInt RFileBuf64::DoFileWrite2(TInt64 aNewFilePos)
   960 	{
   854 	{
   961 	__FBUF64_ASSERT(aNewFilePos >= 0, EFBufPanicFilePos);
   855 	__ASSERT_DEBUG(aNewFilePos >= 0, __SQLITEPANIC(EFBufPanicFilePos));
   962 	__FILEBUF64_INVARIANT();
   856 	__FILEBUF64_INVARIANT();
   963 	TInt err = KErrNone;
   857 	TInt err = KErrNone;
   964 	if(iDirty)
   858 	if(iDirty)
   965 		{
   859 		{
   966 		err = DoFileWrite();
   860 		err = DoFileWrite();
  1007 
   901 
  1008 /**
   902 /**
  1009 RFileBuf64 invariant. Called in _DEBUG mode at the beginning and before the end of every RFileBuf64 method
   903 RFileBuf64 invariant. Called in _DEBUG mode at the beginning and before the end of every RFileBuf64 method
  1010 (except the init/destroy methods).
   904 (except the init/destroy methods).
  1011 
   905 
  1012 @panic FBuf64  11 In _DEBUG mode - null "this" pointer.
   906 @panic Sqlite3  11 In _DEBUG mode - null "this" pointer.
  1013 @panic FBuf64   1 In _DEBUG mode - negative iCapacity value.
   907 @panic Sqlite3   1 In _DEBUG mode - negative iCapacity value.
  1014 @panic FBuf64   2 In _DEBUG mode - the buffer pointer is null (possible the buffer is not allocated or already destroyed).
   908 @panic Sqlite3   2 In _DEBUG mode - the buffer pointer is null (possible the buffer is not allocated or already destroyed).
  1015 @panic FBuf64   3 In _DEBUG mode - invalid iLength value (negative or bigger than iCapacity).
   909 @panic Sqlite3   3 In _DEBUG mode - invalid iLength value (negative or bigger than iCapacity).
  1016 @panic FBuf64   4 In _DEBUG mode - negative iFilePos value.
   910 @panic Sqlite3   4 In _DEBUG mode - negative iFilePos value.
  1017 @panic FBuf64   5 In _DEBUG mode - set but negative iFileSize value.
   911 @panic Sqlite3   5 In _DEBUG mode - set but negative iFileSize value.
  1018 @panic FBuf64   6 In _DEBUG mode - null file handle (the RFile64 object is not created or already destroyed).
   912 @panic Sqlite3   6 In _DEBUG mode - null file handle (the RFile64 object is not created or already destroyed).
  1019 @panic FBuf64  13 In _DEBUG mode - set but negative iNextReadFilePos value.
   913 @panic Sqlite3  13 In _DEBUG mode - set but negative iNextReadFilePos value.
  1020 @panic FBuf64  14 In _DEBUG mode - negative iNextReadFilePosHits value.
   914 @panic Sqlite3  14 In _DEBUG mode - negative iNextReadFilePosHits value.
  1021 @panic FBuf64  15 In _DEBUG mode - iReadAheadSize is negative or is not power of two.
   915 @panic Sqlite3  15 In _DEBUG mode - iReadAheadSize is negative or is not power of two.
  1022 */
   916 */
  1023 void RFileBuf64::Invariant() const
   917 void RFileBuf64::Invariant() const
  1024 	{
   918 	{
  1025 	__FBUF64_ASSERT(this != 0, EFBufPanicNullThis);
   919 	__ASSERT_DEBUG(this != 0, __SQLITEPANIC(EFBufPanicNullThis));
  1026 	__FBUF64_ASSERT(iCapacity > 0, EFBufPanicCapacity);
   920 	__ASSERT_DEBUG(iCapacity > 0, __SQLITEPANIC(EFBufPanicCapacity));
  1027 	__FBUF64_ASSERT(iBase != 0, EFBufPanicNullBuf);
   921 	__ASSERT_DEBUG(iBase != 0, __SQLITEPANIC(EFBufPanicNullBuf));
  1028 	__FBUF64_ASSERT(iLength >= 0 && iLength <= iCapacity, EFBufPanicBufLen);
   922 	__ASSERT_DEBUG(iLength >= 0 && iLength <= iCapacity, __SQLITEPANIC(EFBufPanicBufLen));
  1029 	__FBUF64_ASSERT(iFilePos >= 0, EFBufPanicFilePos);
   923 	__ASSERT_DEBUG(iFilePos >= 0, __SQLITEPANIC(EFBufPanicFilePos));
  1030 	__FBUF64_ASSERT(iFileSize == KFileSizeNotSet || iFileSize >= 0, EFBufPanicFileSize);
   924 	__ASSERT_DEBUG(iFileSize == KFileSizeNotSet || iFileSize >= 0, __SQLITEPANIC(EFBufPanicFileSize));
  1031 	__FBUF64_ASSERT(iFile.SubSessionHandle() != 0, EFBufPanicFileHandle);
   925 	__ASSERT_DEBUG(iFile.SubSessionHandle() != 0, __SQLITEPANIC(EFBufPanicFileHandle));
  1032 	__FBUF64_ASSERT(iNextReadFilePos == KNextReadFilePosNotSet || iNextReadFilePos >= 0, EFBufPanicNextReadFilePos);
   926 	__ASSERT_DEBUG(iNextReadFilePos == KNextReadFilePosNotSet || iNextReadFilePos >= 0, __SQLITEPANIC(EFBufPanicNextReadFilePos));
  1033 	__FBUF64_ASSERT(iNextReadFilePosHits >= 0, EFBufPanicNextReadFilePosHits);
   927 	__ASSERT_DEBUG(iNextReadFilePosHits >= 0, __SQLITEPANIC(EFBufPanicNextReadFilePosHits));
  1034 	__FBUF64_ASSERT(iReadAheadSize > 0 && (iReadAheadSize & (iReadAheadSize - 1)) == 0, EFBufPanicFileBlockSize);
   928 	__ASSERT_DEBUG(iReadAheadSize > 0 && (iReadAheadSize & (iReadAheadSize - 1)) == 0, __SQLITEPANIC(EFBufPanicFileBlockSize));
  1035 	}
   929 	}
  1036 	
   930 	
  1037 #endif
   931 #endif