sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32\sfat\sl_dir.cpp sl@0: // sl@0: // sl@0: sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!! sl@0: //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it sl@0: //!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: sl@0: #include "sl_std.h" sl@0: sl@0: CFatDirCB* CFatDirCB::NewL() sl@0: // sl@0: // Static constructor sl@0: // sl@0: { sl@0: sl@0: CFatDirCB* fatDirCB=new(ELeave) CFatDirCB; sl@0: return fatDirCB; sl@0: } sl@0: sl@0: CFatDirCB::CFatDirCB() sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: } sl@0: sl@0: CFatDirCB::~CFatDirCB() sl@0: // sl@0: // Destructor sl@0: // sl@0: { sl@0: sl@0: delete iMatch; sl@0: delete iLongNameBuf; sl@0: } sl@0: sl@0: void CFatDirCB::SetDirL(const TFatDirEntry& anEntry,const TDesC& aName) sl@0: // sl@0: // Set the current entry to anEntryAddr sl@0: // sl@0: { sl@0: sl@0: __PRINT(_L("CFatDirCB::SetDirL")); sl@0: // iEntryAddr=0; sl@0: // iPending=EFalse; sl@0: iEntry=anEntry; sl@0: iCurrentPos.iCluster= FatMount().StartCluster(iEntry); sl@0: iMatch=aName.AllocL(); sl@0: if (iUidType[0]!=TUid::Null() || iUidType[1]!=TUid::Null() || iUidType[2]!=TUid::Null()) sl@0: iMatchUid=ETrue; sl@0: } sl@0: sl@0: LOCAL_C TBool CompareUid(const TUidType& aUidTrg, const TUidType& aUidSuitor) sl@0: // sl@0: // Compare the suitor to the target pattern sl@0: // sl@0: { sl@0: sl@0: if (aUidTrg[0]!=TUid::Null() && aUidTrg[0]!=aUidSuitor[0]) sl@0: return(EFalse); sl@0: if (aUidTrg[1]!=TUid::Null() && aUidTrg[1]!=aUidSuitor[1]) sl@0: return(EFalse); sl@0: if (aUidTrg[2]!=TUid::Null() && aUidTrg[2]!=aUidSuitor[2]) sl@0: return(EFalse); sl@0: return(ETrue); sl@0: } sl@0: sl@0: void CFatDirCB::ReadL(TEntry &anEntry) sl@0: // sl@0: // Read the next entry from the directory. sl@0: // sl@0: { sl@0: sl@0: __PRINT(_L("CFatDirCB::ReadL")); sl@0: sl@0: FatMount().CheckStateConsistentL(); sl@0: sl@0: sl@0: Mem::FillZ(&anEntry.iType,sizeof(TUidType)); sl@0: sl@0: TPtr entryName(anEntry.iName.Des()); sl@0: FOREVER sl@0: { sl@0: if (iPending) sl@0: entryName=(*iLongNameBuf); sl@0: else sl@0: { sl@0: FatMount().FindDosNameL(*iMatch,iAtt,iCurrentPos,iEntry,entryName,KErrEof); sl@0: FatMount().MoveToNextEntryL(iCurrentPos); sl@0: } sl@0: iPending=EFalse; sl@0: if (iEntry.Attributes()&~KEntryAttMaskSupported) sl@0: continue; // Ignore illegal entries sl@0: anEntry.iAtt=iEntry.Attributes(); sl@0: anEntry.iSize=iEntry.Size(); sl@0: anEntry.iModified=iEntry.Time(FatMount().TimeOffset() ); sl@0: sl@0: if (entryName.Length()==0) sl@0: { sl@0: // VFAT entry names are always created for UNICODE at an earlier stage sl@0: // However, UNICODE builds may still encounter genuine FAT filenames through sl@0: // the introduction of files created using a narrow (ASCII) build sl@0: TBuf8<0x20> dosName(DosNameFromStdFormat(iEntry.Name())); sl@0: LocaleUtils::ConvertToUnicodeL(entryName, dosName); sl@0: } sl@0: TBool matchedUid=ETrue; sl@0: if (iMatchUid && (anEntry.iAtt&KEntryAttDir)==EFalse) sl@0: { sl@0: if ((TUint)anEntry.iSize>=sizeof(TCheckedUid)) sl@0: FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry); sl@0: if (CompareUid(iUidType,anEntry.iType)==EFalse) sl@0: matchedUid=EFalse; sl@0: } sl@0: sl@0: if (matchedUid) sl@0: break; sl@0: } sl@0: if ((iAtt&KEntryAttAllowUid)==0 || (anEntry.iAtt&KEntryAttDir) || (TUint)anEntry.iSize