os/kernelhwsrv/userlibandfileserver/fileserver/sfat32/sl_dir.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat32/sl_dir.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,146 @@
     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 +#include "sl_std.h"
    1.22 +
    1.23 +CFatDirCB* CFatDirCB::NewL()
    1.24 +//
    1.25 +// Static constructor
    1.26 +//
    1.27 +	{
    1.28 +
    1.29 +	CFatDirCB* fatDirCB=new(ELeave) CFatDirCB;
    1.30 +	return fatDirCB;
    1.31 +	}
    1.32 +
    1.33 +CFatDirCB::CFatDirCB()
    1.34 +//
    1.35 +// Constructor
    1.36 +//
    1.37 +	{
    1.38 +	}
    1.39 +
    1.40 +CFatDirCB::~CFatDirCB()
    1.41 +//
    1.42 +// Destructor
    1.43 +//
    1.44 +	{
    1.45 +	
    1.46 +	delete iMatch;
    1.47 +	delete iLongNameBuf;
    1.48 +	}
    1.49 +
    1.50 +void CFatDirCB::SetDirL(const TFatDirEntry& anEntry,const TDesC& aName)
    1.51 +//
    1.52 +// Set the current entry to anEntryAddr
    1.53 +//
    1.54 +	{
    1.55 +
    1.56 +	__PRINT(_L("CFatDirCB::SetDirL"));	
    1.57 +//	iEntryAddr=0;
    1.58 +//	iPending=EFalse;
    1.59 +	iEntry=anEntry;
    1.60 +	iCurrentPos.iCluster= FatMount().StartCluster(iEntry);
    1.61 +	iMatch=aName.AllocL();
    1.62 +	if (iUidType[0]!=TUid::Null() || iUidType[1]!=TUid::Null() || iUidType[2]!=TUid::Null())
    1.63 +		iMatchUid=ETrue;
    1.64 +	}
    1.65 +
    1.66 +LOCAL_C TBool CompareUid(const TUidType& aUidTrg, const TUidType& aUidSuitor)
    1.67 +//
    1.68 +// Compare the suitor to the target pattern
    1.69 +//
    1.70 +	{
    1.71 +	
    1.72 +	if (aUidTrg[0]!=TUid::Null() && aUidTrg[0]!=aUidSuitor[0])
    1.73 +		return(EFalse);
    1.74 +	if (aUidTrg[1]!=TUid::Null() && aUidTrg[1]!=aUidSuitor[1])
    1.75 +		return(EFalse);
    1.76 +	if (aUidTrg[2]!=TUid::Null() && aUidTrg[2]!=aUidSuitor[2])
    1.77 +		return(EFalse);
    1.78 +	return(ETrue);
    1.79 +	}
    1.80 +
    1.81 +void CFatDirCB::ReadL(TEntry &anEntry)
    1.82 +//
    1.83 +// Read the next entry from the directory.
    1.84 +//
    1.85 +	{
    1.86 +
    1.87 +	__PRINT(_L("CFatDirCB::ReadL"));
    1.88 +    
    1.89 +    FatMount().CheckStateConsistentL();
    1.90 +    
    1.91 +
    1.92 +	Mem::FillZ(&anEntry.iType,sizeof(TUidType));
    1.93 +
    1.94 +	TPtr entryName(anEntry.iName.Des());
    1.95 +	FOREVER
    1.96 +		{
    1.97 +		if (iPending)
    1.98 +			entryName=(*iLongNameBuf);
    1.99 +		else
   1.100 +			{
   1.101 +            FatMount().FindDosNameL(*iMatch,iAtt,iCurrentPos,iEntry,entryName,KErrEof);
   1.102 +			FatMount().MoveToNextEntryL(iCurrentPos);
   1.103 +			}
   1.104 +		iPending=EFalse;
   1.105 +		if (iEntry.Attributes()&~KEntryAttMaskSupported)
   1.106 +			continue; // Ignore illegal entries
   1.107 +		anEntry.iAtt=iEntry.Attributes();
   1.108 +		anEntry.iSize=iEntry.Size();
   1.109 +		anEntry.iModified=iEntry.Time(FatMount().TimeOffset() );
   1.110 +	
   1.111 +		if (entryName.Length()==0)
   1.112 +			{
   1.113 +			//	VFAT entry names are always created for UNICODE at an earlier stage
   1.114 +			//	However, UNICODE builds may still encounter genuine FAT filenames through
   1.115 +			//	the introduction of files created using a narrow (ASCII) build
   1.116 +			TBuf8<0x20> dosName(DosNameFromStdFormat(iEntry.Name()));
   1.117 +			LocaleUtils::ConvertToUnicodeL(entryName, dosName);
   1.118 +			}
   1.119 +		TBool matchedUid=ETrue;
   1.120 +		if (iMatchUid && (anEntry.iAtt&KEntryAttDir)==EFalse)
   1.121 +			{
   1.122 +			if ((TUint)anEntry.iSize>=sizeof(TCheckedUid))
   1.123 +				FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry);
   1.124 +			if (CompareUid(iUidType,anEntry.iType)==EFalse)
   1.125 +				matchedUid=EFalse;
   1.126 +			}
   1.127 +					
   1.128 +		if (matchedUid)
   1.129 +			break;
   1.130 +		}
   1.131 +	if ((iAtt&KEntryAttAllowUid)==0 || (anEntry.iAtt&KEntryAttDir) || (TUint)anEntry.iSize<sizeof(TCheckedUid))
   1.132 +		return;
   1.133 +	if (iMatchUid==EFalse)
   1.134 +		{
   1.135 +		TInt r;
   1.136 +		TRAP(r,FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry));
   1.137 +		if(r!=KErrNone && r!=KErrCorrupt)
   1.138 +			User::Leave(r);
   1.139 +		}
   1.140 +	}
   1.141 +
   1.142 +void CFatDirCB::StoreLongEntryNameL(const TDesC& aName)
   1.143 +//
   1.144 +// Store aName while next read is pending
   1.145 +//
   1.146 +	{
   1.147 +
   1.148 +	AllocBufferL(iLongNameBuf,aName);
   1.149 +	}