First public contribution.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfat\sl_dir.cpp
20 CFatDirCB* CFatDirCB::NewL()
26 CFatDirCB* fatDirCB=new(ELeave) CFatDirCB;
30 CFatDirCB::CFatDirCB()
37 CFatDirCB::~CFatDirCB()
47 void CFatDirCB::SetDirL(const TFatDirEntry& anEntry,const TDesC& aName)
49 // Set the current entry to anEntryAddr
53 __PRINT(_L("CFatDirCB::SetDirL"));
57 iCurrentPos.iCluster= FatMount().StartCluster(iEntry);
58 iMatch=aName.AllocL();
59 if (iUidType[0]!=TUid::Null() || iUidType[1]!=TUid::Null() || iUidType[2]!=TUid::Null())
63 LOCAL_C TBool CompareUid(const TUidType& aUidTrg, const TUidType& aUidSuitor)
65 // Compare the suitor to the target pattern
69 if (aUidTrg[0]!=TUid::Null() && aUidTrg[0]!=aUidSuitor[0])
71 if (aUidTrg[1]!=TUid::Null() && aUidTrg[1]!=aUidSuitor[1])
73 if (aUidTrg[2]!=TUid::Null() && aUidTrg[2]!=aUidSuitor[2])
78 void CFatDirCB::ReadL(TEntry &anEntry)
80 // Read the next entry from the directory.
84 __PRINT(_L("CFatDirCB::ReadL"));
86 FatMount().CheckStateConsistentL();
89 Mem::FillZ(&anEntry.iType,sizeof(TUidType));
91 TPtr entryName(anEntry.iName.Des());
95 entryName=(*iLongNameBuf);
98 FatMount().FindDosNameL(*iMatch,iAtt,iCurrentPos,iEntry,entryName,KErrEof);
99 FatMount().MoveToNextEntryL(iCurrentPos);
102 if (iEntry.Attributes()&~KEntryAttMaskSupported)
103 continue; // Ignore illegal entries
104 anEntry.iAtt=iEntry.Attributes();
105 anEntry.iSize=iEntry.Size();
106 anEntry.iModified=iEntry.Time(FatMount().TimeOffset() );
108 if (entryName.Length()==0)
110 // VFAT entry names are always created for UNICODE at an earlier stage
111 // However, UNICODE builds may still encounter genuine FAT filenames through
112 // the introduction of files created using a narrow (ASCII) build
113 TBuf8<0x20> dosName(DosNameFromStdFormat(iEntry.Name()));
114 LocaleUtils::ConvertToUnicodeL(entryName, dosName);
116 TBool matchedUid=ETrue;
117 if (iMatchUid && (anEntry.iAtt&KEntryAttDir)==EFalse)
119 if ((TUint)anEntry.iSize>=sizeof(TCheckedUid))
120 FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry);
121 if (CompareUid(iUidType,anEntry.iType)==EFalse)
128 if ((iAtt&KEntryAttAllowUid)==0 || (anEntry.iAtt&KEntryAttDir) || (TUint)anEntry.iSize<sizeof(TCheckedUid))
130 if (iMatchUid==EFalse)
133 TRAP(r,FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry));
134 if(r!=KErrNone && r!=KErrCorrupt)
139 void CFatDirCB::StoreLongEntryNameL(const TDesC& aName)
141 // Store aName while next read is pending
145 AllocBufferL(iLongNameBuf,aName);