author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// |
sl@0 | 15 |
|
sl@0 | 16 |
#include "BAFINDF.H" |
sl@0 | 17 |
|
sl@0 | 18 |
// |
sl@0 | 19 |
// class CFindFileByType |
sl@0 | 20 |
// |
sl@0 | 21 |
|
sl@0 | 22 |
EXPORT_C CFindFileByType::CFindFileByType(RFs& aFs) |
sl@0 | 23 |
// |
sl@0 | 24 |
// Constructor |
sl@0 | 25 |
// |
sl@0 | 26 |
: iFind(aFs) |
sl@0 | 27 |
{ |
sl@0 | 28 |
__DECLARE_NAME(_S("CFindFileByType")); |
sl@0 | 29 |
} |
sl@0 | 30 |
|
sl@0 | 31 |
EXPORT_C CFindFileByType::~CFindFileByType() |
sl@0 | 32 |
// |
sl@0 | 33 |
// Destructor |
sl@0 | 34 |
// |
sl@0 | 35 |
{ |
sl@0 | 36 |
CloseDir(); |
sl@0 | 37 |
} |
sl@0 | 38 |
|
sl@0 | 39 |
EXPORT_C TInt CFindFileByType::FindFirst(const TDesC& aName,const TDesC& aDir,const TUidType& aType) |
sl@0 | 40 |
// |
sl@0 | 41 |
// Look for first file |
sl@0 | 42 |
// |
sl@0 | 43 |
{ |
sl@0 | 44 |
iType=aType; |
sl@0 | 45 |
CloseDir(); |
sl@0 | 46 |
TInt r=iFind.FindWildByDir(aName,aDir,iDir); |
sl@0 | 47 |
if (r!=KErrNone) |
sl@0 | 48 |
return r; |
sl@0 | 49 |
iCurrentFile=-1; |
sl@0 | 50 |
return FindNext(); |
sl@0 | 51 |
} |
sl@0 | 52 |
|
sl@0 | 53 |
EXPORT_C TInt CFindFileByType::FindNext() |
sl@0 | 54 |
// |
sl@0 | 55 |
// Look for next file |
sl@0 | 56 |
// |
sl@0 | 57 |
{ |
sl@0 | 58 |
TInt ii=iCurrentFile; |
sl@0 | 59 |
FOREVER |
sl@0 | 60 |
{ |
sl@0 | 61 |
__ASSERT_DEBUG(iDir!=NULL,User::Invariant()); |
sl@0 | 62 |
// |
sl@0 | 63 |
TInt count=iDir->Count(); |
sl@0 | 64 |
while (++ii<count) |
sl@0 | 65 |
{ |
sl@0 | 66 |
const TEntry& entry=(*iDir)[ii]; |
sl@0 | 67 |
TInt id=0; |
sl@0 | 68 |
FOREVER |
sl@0 | 69 |
{ |
sl@0 | 70 |
TUid uid=iType[id]; |
sl@0 | 71 |
if (uid!=KNullUid && uid!=entry[id]) |
sl@0 | 72 |
break; // wrong type |
sl@0 | 73 |
if (++id==KMaxCheckedUid) |
sl@0 | 74 |
{ // we have a matching file |
sl@0 | 75 |
iCurrentFile=ii; |
sl@0 | 76 |
iFile.Set(entry.iName,&iFind.File(),NULL); |
sl@0 | 77 |
return KErrNone; |
sl@0 | 78 |
} |
sl@0 | 79 |
} |
sl@0 | 80 |
} |
sl@0 | 81 |
CloseDir(); |
sl@0 | 82 |
TInt r=iFind.FindWild(iDir); |
sl@0 | 83 |
if (r!=KErrNone) |
sl@0 | 84 |
return r; |
sl@0 | 85 |
ii=-1; |
sl@0 | 86 |
} |
sl@0 | 87 |
} |
sl@0 | 88 |
|
sl@0 | 89 |
EXPORT_C const TEntry& CFindFileByType::Entry() const |
sl@0 | 90 |
{ |
sl@0 | 91 |
return (*iDir)[iCurrentFile]; |
sl@0 | 92 |
} |
sl@0 | 93 |
|
sl@0 | 94 |
void CFindFileByType::CloseDir() |
sl@0 | 95 |
// |
sl@0 | 96 |
// Close iDir |
sl@0 | 97 |
// |
sl@0 | 98 |
{ |
sl@0 | 99 |
delete(iDir); |
sl@0 | 100 |
iDir=NULL; |
sl@0 | 101 |
} |