LOCAL_C void MainL()
	{
	test.Start(_L("@SYMTESTCaseID:PIM-ALLDAYEVENTS-0001 Getting list of all day events data...."));

	RDir dataDir;
	CleanupClosePushL(dataDir);
	//Open the Data directory and read the file entries
	User::LeaveIfError(dataDir.Open(calTestLibrary->FileSession(), KDataDir, KEntryAttNormal));
	
	TEntryArray* dataArray = new (ELeave) TEntryArray();

	CleanupStack::PushL(dataArray);
	
	dataDir.Read(*dataArray);
	
	TInt count = dataArray->Count();
	test (count != 0);
		
	for (TInt i=0; i < count; ++i)
	    {
	    test.Next(_L("ALLDAYEVENTS-0002"));

	    TBuf<256> name;
	    name = KDataDir;
	    name.Append((*dataArray)[i].iName);
	    
	    RPointerArray<CCalEntry> calEntries;
	    CleanupResetAndDestroyPushL(calEntries);
	    ImportEntriesL(name, calEntries);
	    TInt calEntriesCount = calEntries.Count();
	    if (calEntriesCount)	
	        {
	        //Test entry for the presence of timzone rules and UTC
	        CheckTimezoneRules(*calEntries[0]);
	        }
	    name = KWriteDataDir;
	    name.Append((*dataArray)[i].iName);
	    
	    ExportEntriesL(calEntries, name);
	    
	    TBool result = TestExportedFile(name);
	    
	    if (result)
	        {
	    	calTestLibrary->FileSession().Delete(name);
	        }
	    
	    CleanupStack::PopAndDestroy(&calEntries);
	    }
	
	CleanupStack::PopAndDestroy(dataArray);
	CleanupStack::PopAndDestroy(&dataDir);
	// This will fail if there was a parsing error in one or more of the data files
	// which will still be then present in the directory for inspecting.
	test (calTestLibrary->FileSession().RmDir(KWriteDataDir) == KErrNone);
	
	test.End();
	test.Close();
	}
// -----------------------------------------------------------------------------
// CDirectoryDesc::Read : Reading from a Directory
// -----------------------------------------------------------------------------
void CDirectoryDesc::Read(TDes8& aDesc, TRequestStatus& aStatus)
{
    TInt errorNum = KErrNone;
    const TInt16 KDirentSize = 8;
    TInt readLen = aDesc.MaxLength();
    TUint8* bufPtr = const_cast<TUint8*>(aDesc.Ptr());
    TInt copiedInfo = 0;
    TEntryArray entries;
    errorNum = iDir.Read( entries );
    TDirent direntEntry;

    if (errorNum == KErrNone || errorNum == KErrEof)
    {
        errorNum = KErrNone;
        TEntry entry;
        TInt len = 0;
        TInt count = entries.Count();
        TBuf8<KMaxFileName> fileName;
        TInt index = 0;
        TInt copyLen = 0;
        //Loop through each entry and get all the informations
        for (; index<count && copiedInfo<readLen; index++, copiedInfo += copyLen)
        {
            entry = entries[index];
            //Copy File's UID
            TUid fileUID = entry.iType.MostDerived();
            direntEntry.iEntryNum = fileUID.iUid;
            HBufC8 *name;
            if(ConvertUnicodeToUtf8(entry.iName,name,errorNum) == -1)
            {
                break;
            }
            //Copy entry type and record Length
            fileName.Copy( name->Des() );
            delete name;
            len = fileName.Length();
            direntEntry.iRecLen = KDirentSize + len + 1;
            //Maintaing a four byte boundary.
            direntEntry.iRecLen = Align4(direntEntry.iRecLen);
            direntEntry.iEntryType = 0;
            direntEntry.iNameLen = len;
            //Copy entry name
            Mem::Copy( direntEntry.iEntryName, fileName.PtrZ(), len+1);

            //Copy structure on to the buffer
            copyLen = Min(direntEntry.iRecLen, (readLen - copiedInfo));
            Mem::Copy( bufPtr, &direntEntry, copyLen );
            bufPtr += copyLen;
        }
    }

    //Set the Length
    aDesc.SetLength( copiedInfo );
    TRequestStatus* status = &aStatus;
    User::RequestComplete(status, errorNum);
}