Пример #1
0
/**
Searches the cache for the particular recognition result. If the file was not modified since the
file was recognized, the stored recognition result is returned.

N.B. The returned value is reference counted!
@internalComponent
*/
CRecognitionResult* CApsRecognitionCache::DoGet(const TDesC& aDirectory, const TDesC& aFileName, const TTime& aLastModified)
	{	
	CRecognitionResult* result = NULL;
	CCacheDirectoryEntry* entry;

    iIter.SetToFirst();
    while ((entry = iIter++) != NULL)
    	{
    	if(CompareDirectories(entry->Directory(),aDirectory))
    		{
    		TTime cachedLastModified;
			result = entry->Files().Get(aFileName, cachedLastModified);
			if(result)
				{
				if(cachedLastModified != aLastModified)
					{
					result->Close();
					result = NULL;
					}
				}

			// move directory to top (it is likely to be used again soon)
			entry->iDlink.Deque();
			iDirectoryHeader.AddFirst(*entry);
			break;
    		}
    	}
	return result;
	}
Пример #2
0
TDataRecognitionResult CApaAppListServer::RecognizeDataL(RFile& aFile, TInt aPreferredBufSize)
	{
	CRecognitionResult* result = RecognizeDataAsCRecognitionResultL(aFile, aPreferredBufSize);
	TDataRecognitionResult ret;
	result->Get(ret);
	result->Close();
	return ret;
	}
Пример #3
0
/**
Searches the cache for the particular recognition result. If the file was not modified since the
file was recognized, the stored recognition result is returned.
@internalComponent
*/
TBool CApsRecognitionCache::Get(const TDesC& aDirectory, const TDesC& aFileName, TDataRecognitionResult& aRecognitionResult)
	{
	TTime lastModified;
	TFileName fileName(aDirectory);
	fileName.Append(aFileName);
	const TInt error = iFs.Modified(fileName, lastModified);
	if(error != KErrNone) 
		{
		return EFalse;
		}

	CRecognitionResult* result = DoGet(aDirectory, aFileName, lastModified);
	if(result)
		{
		result->Get(aRecognitionResult);
		result->Close(); // decrease reference count since we're not exposing the object
		return ETrue;
		}
	return EFalse;
	}