예제 #1
0
FastFileReader::FastFileReader( const lem::Path& filename )
:Stream(true,false,filename)
{
 hFile = NULL;
 hFileMap = NULL;
 OrgAdr = EndAdr = NULL;
 filesize.LowPart = filesize.HighPart = 0;
 binary=true;

 hFile = CreateFileW(
                     filename.GetUnicode().c_str(),
                     GENERIC_READ,
                     FILE_SHARE_READ,
                     NULL,
                     OPEN_EXISTING,
                     0,
                     NULL
                    );

 LEM_CHECKIT_Z(hFile!=(HANDLE)-1);

 if( hFile==(HANDLE)-1 )
  return;

 hFileMap = CreateFileMapping( hFile, NULL, PAGE_READONLY, 0, 0, NULL );
 LEM_CHECKIT_Z(hFileMap!=NULL);

 if( hFileMap==NULL )
  return;

 OrgAdr = (lem::uint8_t*)MapViewOfFile( hFileMap, FILE_MAP_READ, 0, 0, 0 );
 LEM_CHECKIT_Z(OrgAdr!=NULL);

 if( OrgAdr==NULL )
  return;

 #if defined LEM_QT
 quint64 i64 = QFileInfo(filename.GetUnicode().to_qt()).size();
 filesize.QuadPart = i64;
 #elif (defined LEM_MSC && _MSC_VER<1300) || defined LEM_WIN98
 filesize.LowPart = GetFileSize( hFile, (unsigned long*)&filesize.HighPart );
 LEM_CHECKIT_Z( filesize.LowPart!=INVALID_FILE_SIZE );
 #else
 BOOL res = GetFileSizeEx( hFile, &filesize );
 LEM_CHECKIT_Z( res!=0 );
 #endif

 CurAdr = OrgAdr;
 EndAdr = OrgAdr+filesize.LowPart;

 return;
}
예제 #2
0
void NGramsStorage_SQLITE::Connect( const lem::Path &connection_string )
{
 hdb = lem::sqlite_open_serialized(connection_string.GetUnicode());

 lem::sqlite_execute( hdb, "PRAGMA temp_store = MEMORY" );
 return;
}