using namespace Kita;
-// copied from http.cc
// ¥¥ã¥Ã¥·¥å¤¬¤¢¤ë¤È¤¤Ï¤½¤ÎÆâÍƤòmalloc¤·¤¿Îΰè¤Ë¥³¥Ô¡¼¤·¤ÆÊÖ¤¹¡£
// ¥¥ã¥Ã¥·¥å¤¬¤Ê¤¤¤È¤¤Ï0¤òÊÖ¤¹¡£
QCString Access::getCacheData( const KURL& url )
{
QString cachePath = Kita::Cache::getPath( url );
- FILE *fs = fopen( QFile::encodeName( cachePath ), "r" );
- if ( !fs ) {
+ QFile file( cachePath );
+ if ( !file.open( IO_ReadOnly ) ) {
return 0;
}
+ int dataSize = file.size();
- struct stat buf;
- ::stat( QFile::encodeName( cachePath ), &buf );
- int pos = ftell( fs );
- int datasize = buf.st_size - pos;
-
- char* ret = static_cast<char *>( malloc( datasize + 1 ) );
- fread( ret, datasize, 1, fs );
- ret[ datasize ] = '\0';
- fclose( fs );
+ char* ret = static_cast<char *>( malloc( dataSize + 1 ) );
+ file.readBlock( ret, dataSize );
+ ret[ dataSize ] = '\0';
return ret;
}