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
18 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 CFatDirCB* CFatDirCB::NewL()
34 CFatDirCB* fatDirCB=new(ELeave) CFatDirCB;
38 CFatDirCB::CFatDirCB()
45 CFatDirCB::~CFatDirCB()
55 void CFatDirCB::SetDirL(const TFatDirEntry& anEntry,const TDesC& aName)
57 // Set the current entry to anEntryAddr
61 __PRINT(_L("CFatDirCB::SetDirL"));
65 iCurrentPos.iCluster= FatMount().StartCluster(iEntry);
66 iMatch=aName.AllocL();
67 if (iUidType[0]!=TUid::Null() || iUidType[1]!=TUid::Null() || iUidType[2]!=TUid::Null())
71 LOCAL_C TBool CompareUid(const TUidType& aUidTrg, const TUidType& aUidSuitor)
73 // Compare the suitor to the target pattern
77 if (aUidTrg[0]!=TUid::Null() && aUidTrg[0]!=aUidSuitor[0])
79 if (aUidTrg[1]!=TUid::Null() && aUidTrg[1]!=aUidSuitor[1])
81 if (aUidTrg[2]!=TUid::Null() && aUidTrg[2]!=aUidSuitor[2])
86 void CFatDirCB::ReadL(TEntry &anEntry)
88 // Read the next entry from the directory.
92 __PRINT(_L("CFatDirCB::ReadL"));
94 FatMount().CheckStateConsistentL();
97 Mem::FillZ(&anEntry.iType,sizeof(TUidType));
99 TPtr entryName(anEntry.iName.Des());
103 entryName=(*iLongNameBuf);
106 FatMount().FindDosNameL(*iMatch,iAtt,iCurrentPos,iEntry,entryName,KErrEof);
107 FatMount().MoveToNextEntryL(iCurrentPos);
110 if (iEntry.Attributes()&~KEntryAttMaskSupported)
111 continue; // Ignore illegal entries
112 anEntry.iAtt=iEntry.Attributes();
113 anEntry.iSize=iEntry.Size();
114 anEntry.iModified=iEntry.Time(FatMount().TimeOffset() );
116 if (entryName.Length()==0)
118 // VFAT entry names are always created for UNICODE at an earlier stage
119 // However, UNICODE builds may still encounter genuine FAT filenames through
120 // the introduction of files created using a narrow (ASCII) build
121 TBuf8<0x20> dosName(DosNameFromStdFormat(iEntry.Name()));
122 LocaleUtils::ConvertToUnicodeL(entryName, dosName);
124 TBool matchedUid=ETrue;
125 if (iMatchUid && (anEntry.iAtt&KEntryAttDir)==EFalse)
127 if ((TUint)anEntry.iSize>=sizeof(TCheckedUid))
128 FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry);
129 if (CompareUid(iUidType,anEntry.iType)==EFalse)
136 if ((iAtt&KEntryAttAllowUid)==0 || (anEntry.iAtt&KEntryAttDir) || (TUint)anEntry.iSize<sizeof(TCheckedUid))
138 if (iMatchUid==EFalse)
141 TRAP(r,FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry));
142 if(r!=KErrNone && r!=KErrCorrupt)
147 void CFatDirCB::StoreLongEntryNameL(const TDesC& aName)
149 // Store aName while next read is pending
153 AllocBufferL(iLongNameBuf,aName);