1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_dir.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,154 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32\sfat\sl_dir.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.22 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.23 +//!!
1.24 +//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
1.25 +//!!
1.26 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.27 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.28 +
1.29 +#include "sl_std.h"
1.30 +
1.31 +CFatDirCB* CFatDirCB::NewL()
1.32 +//
1.33 +// Static constructor
1.34 +//
1.35 + {
1.36 +
1.37 + CFatDirCB* fatDirCB=new(ELeave) CFatDirCB;
1.38 + return fatDirCB;
1.39 + }
1.40 +
1.41 +CFatDirCB::CFatDirCB()
1.42 +//
1.43 +// Constructor
1.44 +//
1.45 + {
1.46 + }
1.47 +
1.48 +CFatDirCB::~CFatDirCB()
1.49 +//
1.50 +// Destructor
1.51 +//
1.52 + {
1.53 +
1.54 + delete iMatch;
1.55 + delete iLongNameBuf;
1.56 + }
1.57 +
1.58 +void CFatDirCB::SetDirL(const TFatDirEntry& anEntry,const TDesC& aName)
1.59 +//
1.60 +// Set the current entry to anEntryAddr
1.61 +//
1.62 + {
1.63 +
1.64 + __PRINT(_L("CFatDirCB::SetDirL"));
1.65 +// iEntryAddr=0;
1.66 +// iPending=EFalse;
1.67 + iEntry=anEntry;
1.68 + iCurrentPos.iCluster= FatMount().StartCluster(iEntry);
1.69 + iMatch=aName.AllocL();
1.70 + if (iUidType[0]!=TUid::Null() || iUidType[1]!=TUid::Null() || iUidType[2]!=TUid::Null())
1.71 + iMatchUid=ETrue;
1.72 + }
1.73 +
1.74 +LOCAL_C TBool CompareUid(const TUidType& aUidTrg, const TUidType& aUidSuitor)
1.75 +//
1.76 +// Compare the suitor to the target pattern
1.77 +//
1.78 + {
1.79 +
1.80 + if (aUidTrg[0]!=TUid::Null() && aUidTrg[0]!=aUidSuitor[0])
1.81 + return(EFalse);
1.82 + if (aUidTrg[1]!=TUid::Null() && aUidTrg[1]!=aUidSuitor[1])
1.83 + return(EFalse);
1.84 + if (aUidTrg[2]!=TUid::Null() && aUidTrg[2]!=aUidSuitor[2])
1.85 + return(EFalse);
1.86 + return(ETrue);
1.87 + }
1.88 +
1.89 +void CFatDirCB::ReadL(TEntry &anEntry)
1.90 +//
1.91 +// Read the next entry from the directory.
1.92 +//
1.93 + {
1.94 +
1.95 + __PRINT(_L("CFatDirCB::ReadL"));
1.96 +
1.97 + FatMount().CheckStateConsistentL();
1.98 +
1.99 +
1.100 + Mem::FillZ(&anEntry.iType,sizeof(TUidType));
1.101 +
1.102 + TPtr entryName(anEntry.iName.Des());
1.103 + FOREVER
1.104 + {
1.105 + if (iPending)
1.106 + entryName=(*iLongNameBuf);
1.107 + else
1.108 + {
1.109 + FatMount().FindDosNameL(*iMatch,iAtt,iCurrentPos,iEntry,entryName,KErrEof);
1.110 + FatMount().MoveToNextEntryL(iCurrentPos);
1.111 + }
1.112 + iPending=EFalse;
1.113 + if (iEntry.Attributes()&~KEntryAttMaskSupported)
1.114 + continue; // Ignore illegal entries
1.115 + anEntry.iAtt=iEntry.Attributes();
1.116 + anEntry.iSize=iEntry.Size();
1.117 + anEntry.iModified=iEntry.Time(FatMount().TimeOffset() );
1.118 +
1.119 + if (entryName.Length()==0)
1.120 + {
1.121 + // VFAT entry names are always created for UNICODE at an earlier stage
1.122 + // However, UNICODE builds may still encounter genuine FAT filenames through
1.123 + // the introduction of files created using a narrow (ASCII) build
1.124 + TBuf8<0x20> dosName(DosNameFromStdFormat(iEntry.Name()));
1.125 + LocaleUtils::ConvertToUnicodeL(entryName, dosName);
1.126 + }
1.127 + TBool matchedUid=ETrue;
1.128 + if (iMatchUid && (anEntry.iAtt&KEntryAttDir)==EFalse)
1.129 + {
1.130 + if ((TUint)anEntry.iSize>=sizeof(TCheckedUid))
1.131 + FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry);
1.132 + if (CompareUid(iUidType,anEntry.iType)==EFalse)
1.133 + matchedUid=EFalse;
1.134 + }
1.135 +
1.136 + if (matchedUid)
1.137 + break;
1.138 + }
1.139 + if ((iAtt&KEntryAttAllowUid)==0 || (anEntry.iAtt&KEntryAttDir) || (TUint)anEntry.iSize<sizeof(TCheckedUid))
1.140 + return;
1.141 + if (iMatchUid==EFalse)
1.142 + {
1.143 + TInt r;
1.144 + TRAP(r,FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry));
1.145 + if(r!=KErrNone && r!=KErrCorrupt)
1.146 + User::Leave(r);
1.147 + }
1.148 + }
1.149 +
1.150 +void CFatDirCB::StoreLongEntryNameL(const TDesC& aName)
1.151 +//
1.152 +// Store aName while next read is pending
1.153 +//
1.154 + {
1.155 +
1.156 + AllocBufferL(iLongNameBuf,aName);
1.157 + }