author | hgs |
Wed, 20 Oct 2010 13:58:28 +0100 | |
changeset 293 | 0659d0e1a03c |
parent 90 | 947f0dc9f7a8 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32\sfsrv\cl_find.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "cl_std.h" |
|
19 |
||
20 |
#define gPathDelimiter TChar(';') |
|
21 |
enum TMode {EFindByDrives,EFindByDrivesInPath,EFindByPath}; |
|
22 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
|
0 | 24 |
// |
25 |
// Look for aFileName in aDir |
|
26 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
TInt TFindFile::DoFindInDir() |
0 | 28 |
{ |
29 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
if (!iDir) |
0 | 31 |
{ |
32 |
TEntry entry; |
|
33 |
TInt r=iFs->Entry(iFile.FullName(),entry); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
if (r != KErrNone && r != KErrNoMemory && r != KErrPermissionDenied) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
r = KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
37 |
|
0 | 38 |
return r; |
39 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
40 |
|
0 | 41 |
TInt r=iFs->GetDir(iFile.FullName(),KEntryAttMaskSupported|KEntryAttAllowUid,ESortByName,*iDir); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
if(r == KErrNone) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
if(!(*iDir)->Count()) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
r = KErrNotFound; //-- empty directory |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
else if(r != KErrNoMemory && r != KErrPermissionDenied) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
50 |
r = KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
51 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
if (r != KErrNone && iDir) |
0 | 54 |
{ |
55 |
delete (*iDir); |
|
56 |
*iDir=NULL; |
|
57 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
return r; |
0 | 60 |
} |
61 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
|
0 | 63 |
// |
64 |
// Look for aFileName along the path and increment aPathPos |
|
65 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
TInt TFindFile::DoFindNextInPath() |
0 | 67 |
{ |
68 |
||
69 |
if (iMode==EFindByDrivesInPath) |
|
70 |
{ |
|
71 |
TInt r=DoFindNextInDriveList(); |
|
72 |
if (r!=KErrNotFound) |
|
73 |
return(r); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
|
0 | 75 |
iMode=EFindByPath; |
76 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
77 |
|
0 | 78 |
FOREVER |
79 |
{ |
|
80 |
if (iPath->Length()<iPathPos) |
|
81 |
return(KErrNotFound); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
|
0 | 83 |
TPtrC path(iPath->Ptr()+iPathPos,iPath->Length()-iPathPos); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
|
0 | 85 |
TInt r=path.Locate(gPathDelimiter); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
|
0 | 87 |
if (r==KErrNotFound) |
88 |
r=path.Length(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
|
0 | 90 |
path.Set(path.Ptr(),r); |
91 |
iPathPos+=r+1; |
|
92 |
TFileName fileName=iFile.NameAndExt(); |
|
93 |
iFile.Set(fileName,&path,NULL); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
|
0 | 95 |
if (iFile.FullName().Length()>=2 && iFile.FullName()[1]==KDriveDelimiter) |
96 |
{ |
|
97 |
TInt r=DoFindInDir(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
if (r == KErrNotFound) |
0 | 99 |
continue; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
101 |
return(r); |
0 | 102 |
} |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
103 |
|
0 | 104 |
iMode=EFindByDrivesInPath; |
105 |
||
106 |
r=FindByDir(fileName,path); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
108 |
if (r == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
109 |
continue; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
110 |
|
0 | 111 |
return(r); |
112 |
} |
|
113 |
||
114 |
} |
|
115 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
|
0 | 117 |
// |
118 |
// Look for aFileName in all available drives in order |
|
119 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
TInt TFindFile::DoFindNextInDriveList() |
0 | 121 |
{ |
122 |
||
123 |
TInt found; |
|
124 |
TDriveInfo driveInfo; |
|
125 |
const TUint matchedFlags= iMatchMask & KDriveAttMatchedFlags; //KDriveAttMatchedFlags = 0xFFF |
|
126 |
const TUint matchedAtt = iMatchMask & KDriveAttMatchedAtt; //KDriveAttMatchedAtt = 0x0FFF0000 |
|
127 |
||
128 |
if (iMatchMask == (KDriveAttExclude | KDriveAttMatchedFlags ) ) //If all drives are excluded. |
|
129 |
return KErrNotFound; |
|
130 |
||
131 |
FOREVER |
|
132 |
{ |
|
133 |
||
134 |
found =0; |
|
135 |
TInt currentDrive=iCurrentDrive; |
|
136 |
||
137 |
||
138 |
if (iCurrentDrive==-1) |
|
139 |
currentDrive=EDriveZ; |
|
140 |
||
141 |
||
142 |
if (currentDrive<=-2) |
|
143 |
return(KErrNotFound); |
|
144 |
||
145 |
||
146 |
iCurrentDrive--; |
|
147 |
||
148 |
if (!iDrvList[currentDrive]) |
|
149 |
continue; |
|
150 |
||
151 |
TInt err = iFs->Drive(driveInfo,currentDrive); |
|
152 |
||
153 |
if(iMatchMask == 0) |
|
154 |
{ |
|
155 |
if (iDrvList[currentDrive] & KDriveAttRemote) |
|
156 |
continue; // NOT allowed on REMOTE DRIVE |
|
157 |
if ((iDrvList[currentDrive] & (KDriveAttLocal|KDriveAttRom))==0) |
|
158 |
continue; |
|
159 |
} |
|
160 |
else |
|
161 |
{ |
|
162 |
||
163 |
if(matchedFlags != 0 ) |
|
164 |
{ |
|
165 |
||
166 |
switch(matchedAtt) |
|
167 |
{ //found ==0 means that this drive attributes didn't match the flags |
|
168 |
||
169 |
case KDriveAttExclude : |
|
170 |
found = (driveInfo.iDriveAtt & matchedFlags ) ? 0:iDrvList[currentDrive] ; |
|
171 |
break; |
|
172 |
||
173 |
case 0: |
|
174 |
found = (driveInfo.iDriveAtt & matchedFlags) ? iDrvList[currentDrive]:0 ; |
|
175 |
break; |
|
176 |
||
177 |
||
178 |
case KDriveAttExclusive : |
|
179 |
if(matchedFlags != KDriveAttLogicallyRemovable) |
|
180 |
{ |
|
181 |
||
182 |
found = ((TUint8)(driveInfo.iDriveAtt) == matchedFlags) ?iDrvList[currentDrive]:0; |
|
183 |
||
184 |
} |
|
185 |
else |
|
186 |
{ |
|
187 |
found = (driveInfo.iDriveAtt == (matchedFlags | KDriveAttRemovable) ) ?iDrvList[currentDrive]:0; |
|
188 |
} |
|
189 |
||
190 |
break; |
|
191 |
||
192 |
case KDriveAttExclude | KDriveAttExclusive: |
|
193 |
if(matchedFlags != KDriveAttLogicallyRemovable) |
|
194 |
{ |
|
195 |
||
196 |
found = ((TUint8)(driveInfo.iDriveAtt) == matchedFlags) ?0:iDrvList[currentDrive]; |
|
197 |
||
198 |
} |
|
199 |
else |
|
200 |
{ |
|
201 |
found = (driveInfo.iDriveAtt == (matchedFlags | KDriveAttRemovable)) ?0:iDrvList[currentDrive]; |
|
202 |
} |
|
203 |
||
204 |
break; |
|
205 |
||
206 |
default: |
|
207 |
Panic(EFindFileIllegalAttribute); |
|
208 |
||
209 |
} |
|
210 |
} |
|
211 |
||
212 |
else //matchedFlags == 0. |
|
213 |
{ |
|
214 |
||
215 |
if (matchedAtt== KDriveAttAll) |
|
216 |
found= iDrvList[currentDrive]; |
|
217 |
else |
|
218 |
Panic(EFindFileIllegalAttribute); |
|
219 |
||
220 |
} |
|
221 |
||
222 |
||
223 |
||
224 |
if( found == 0) |
|
225 |
continue; |
|
226 |
||
227 |
} |
|
228 |
||
229 |
// Don't scan a locked drive |
|
230 |
||
231 |
if( err == KErrNone) |
|
232 |
{ |
|
233 |
if(driveInfo.iMediaAtt & KMediaAttLocked) |
|
234 |
continue; |
|
235 |
} |
|
236 |
||
237 |
||
238 |
TParse fileName; |
|
239 |
TChar driveLetter; |
|
240 |
RFs::DriveToChar(currentDrive,driveLetter); |
|
241 |
TBuf<4> drive; |
|
242 |
drive.SetLength(2); |
|
243 |
drive[0]=(TText)driveLetter; |
|
244 |
drive[1]=':'; |
|
245 |
TPtrC nameAndExt(iFile.NameAndExt()); |
|
246 |
TPtrC path(iFile.Path()); |
|
247 |
fileName.Set(nameAndExt,&path,&drive); |
|
248 |
iFile=fileName; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
249 |
|
0 | 250 |
TInt r=DoFindInDir(); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
251 |
|
0 | 252 |
if (r==KErrNone) |
253 |
return(KErrNone); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
|
0 | 255 |
if (r!=KErrNotFound) |
256 |
return(r); |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
||
261 |
||
262 |
||
263 |
/** |
|
264 |
Constructor taking a file server session. |
|
265 |
||
266 |
@param aFs File server session. |
|
267 |
*/ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
EXPORT_C TFindFile::TFindFile(RFs& aFs) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
:iFs(&aFs), iPathPos(0), iCurrentDrive(0), iMode(-1), iDir(NULL), iMatchMask(0) |
0 | 270 |
{ |
271 |
iFile.Set(_L(""),NULL,NULL); |
|
272 |
} |
|
273 |
||
274 |
||
275 |
||
276 |
||
277 |
TInt TFindFile::DoFindByPath(const TDesC& aFileName,const TDesC* aPath) |
|
278 |
// |
|
279 |
// Look for a file in each directory in the path |
|
280 |
// Make initial check for aFileName in the current directory |
|
281 |
// |
|
282 |
{ |
|
283 |
||
284 |
if (aFileName.Length() <= 0) |
|
285 |
return(KErrArgument); |
|
286 |
||
287 |
TInt r=iFile.Set(aFileName,NULL,NULL); |
|
288 |
if (r!=KErrNone) |
|
289 |
return(r); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
|
0 | 291 |
iPath=aPath; |
292 |
iPathPos=0; |
|
293 |
iMode=EFindByPath; |
|
294 |
r=DoFindInDir(); |
|
295 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
// if it's not in the current dir and a search path was specified, look there. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
if (r == KErrNotFound && iPath && iPath->Length()) |
0 | 298 |
r=DoFindNextInPath(); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
|
0 | 300 |
return(r); |
301 |
} |
|
302 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
303 |
|
0 | 304 |
// |
305 |
// Look for aFileName in aDir on each connected drive |
|
306 |
// Make initial check for aFileName in aDir on current drive |
|
307 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
308 |
TInt TFindFile::DoFindByDir(const TDesC& aFileName,const TDesC& aDir) |
0 | 309 |
{ |
310 |
||
311 |
if (aFileName.Length() <= 0) |
|
312 |
return(KErrArgument); |
|
313 |
||
314 |
TInt r=iFs->Parse(aFileName,aDir,iFile); |
|
315 |
if (r!=KErrNone) |
|
316 |
return(r); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
317 |
|
0 | 318 |
TInt searchResult=DoFindInDir(); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
if(searchResult == KErrNoMemory || searchResult == KErrPermissionDenied) |
0 | 320 |
return(searchResult); |
321 |
||
322 |
r=iFs->DriveList(iDrvList,KDriveAttAll); |
|
323 |
if (r!=KErrNone) |
|
324 |
return(r); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
325 |
|
0 | 326 |
TInt drive; |
327 |
r=RFs::CharToDrive(iFile.Drive()[0],drive); |
|
328 |
if (r!=KErrNone) |
|
329 |
return(r); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
330 |
|
0 | 331 |
iDrvList[drive]=0; // Drive 'drive' has already been searched |
332 |
iCurrentDrive=EDriveY; |
|
333 |
iMode=EFindByDrives; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
|
0 | 335 |
if (searchResult==KErrNone) |
336 |
return(KErrNone); |
|
337 |
||
338 |
||
339 |
return(DoFindNextInDriveList()); |
|
340 |
} |
|
341 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
343 |
internal helper method that deletes the (*iDir) object in the case of errors and assigns NULL to the client's pointer top it. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
TInt TFindFile::CallSafe(TInt aResult) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
346 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
if (aResult != KErrNone && iDir) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
delete *iDir; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
*iDir = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
351 |
iDir = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
352 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
return aResult; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
354 |
} |
0 | 355 |
|
356 |
||
357 |
/** |
|
358 |
Searches for a file/directory in one or more directories in the path. |
|
359 |
||
360 |
The search ends when the file/directory is found, or when every directory |
|
361 |
specified in the path list has been unsuccessfully searched. |
|
362 |
||
363 |
Notes: |
|
364 |
||
365 |
1. For the equivalent search using wildcards, use FindWildByPath(). |
|
366 |
||
367 |
2. After a file has been found, use TFindFile::File() to get the fully qualified path of the file. To |
|
368 |
search for the next occurrence, use TFindFile::Find(). |
|
369 |
||
370 |
@param aFileName The filename to search for. If this specifies a directory as well |
|
371 |
as a filename, then that directory is searched first. |
|
372 |
@param aPath A list of directories to be searched. Paths in this list must |
|
373 |
be separated by a semicolon character, but a semicolon is not |
|
374 |
required after the final path. The directories are searched in |
|
375 |
the order in which they occur in the list. If a path in |
|
376 |
the list contains a drive letter, that drive alone is searched. |
|
377 |
If a path contains no drive letter, the function searches for |
|
378 |
the file in that directory on every available drive in turn, |
|
379 |
beginning with drive Y:, in descending alphabetical order |
|
380 |
and ending with drive Z:.When path is empty then session path |
|
381 |
will be used for the search. |
|
382 |
||
383 |
@return KErrNone, if the filename was found; |
|
384 |
KErrNotFound, if the filename was not found. |
|
385 |
KErrArgument, if the filename is empty. |
|
386 |
||
387 |
@see TFindFile::FindWildByPath |
|
388 |
@see TFindFile::File |
|
389 |
@see TFindFile::Find |
|
390 |
*/ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
391 |
EXPORT_C TInt TFindFile::FindByPath(const TDesC& aFileName,const TDesC* aPath) |
0 | 392 |
{ |
393 |
||
394 |
iDir=NULL; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
395 |
return CallSafe(DoFindByPath(aFileName,aPath)); |
0 | 396 |
} |
397 |
||
398 |
||
399 |
||
400 |
||
401 |
/** |
|
402 |
Searches for a file/directory in a directory on all available drives. |
|
403 |
||
404 |
The search ends when the file/directory is found, or when every available |
|
405 |
drive has been unsuccessfully searched. |
|
406 |
||
407 |
Notes: |
|
408 |
||
409 |
1. A drive letter may be specified in aDirPath. |
|
410 |
If a drive is specified, then that drive is searched first. If no drive is |
|
411 |
specified, then the drive specified in the session path is searched first. |
|
412 |
The remaining available drives are then searched in descending alphabetical |
|
413 |
order, from Y: to A:, and ending with the Z: drive. Using function SetFindMask |
|
414 |
it is possible to specify a combination of attributes that the drives to be |
|
415 |
searched must match. |
|
416 |
||
417 |
||
418 |
2. For the corresponding search using wildcards, use FindWildByDir(). |
|
419 |
||
420 |
3. After a file has been found, use TFindFile::File() to get the fully |
|
421 |
qualified path and filename. To search for the next occurrence, |
|
422 |
use TFindFile::Find(). |
|
423 |
||
424 |
@param aFileName The filename to search for. If a path is specified, it |
|
425 |
overrides the path specified in aDir. If no path is specified, |
|
426 |
the path contained in aDir is used. |
|
427 |
@param aDir A single path indicating a directory to be searched on each |
|
428 |
drive.When path is empty then session path will be used for the search. |
|
429 |
||
430 |
@return KErrNone, if the file was found, otherwise one of the system-wide error codes, including: |
|
431 |
KErrNotFound, if the file was not found; |
|
432 |
KErrPermissionDenied, if the client does not have appropriate capabilities for the directory to be searched; |
|
433 |
KErrArgument, if the filename is empty. |
|
434 |
||
435 |
@see TFindFile::FindWildByDir() |
|
436 |
@see TFindFile::File() |
|
437 |
@see TFindFile::Find() |
|
438 |
@see TFindFile::SetFindMask() |
|
439 |
*/ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
440 |
EXPORT_C TInt TFindFile::FindByDir(const TDesC& aFileName,const TDesC& aDir) |
0 | 441 |
{ |
442 |
||
443 |
iDir=NULL; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
444 |
return CallSafe(DoFindByDir(aFileName,aDir)); |
0 | 445 |
} |
446 |
||
447 |
||
448 |
||
449 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
450 |
|
0 | 451 |
/** |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
452 |
Searches for one or more files/directories in the directories contained in a path list. |
0 | 453 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
454 |
Wildcard characters can be specified. The search ends when one or more filenames matching aFileName is found, or when every |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
455 |
directory in the path list has been unsuccessfully searched. To begin searching again after a successful match has been made, use FindWild(). |
0 | 456 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
457 |
Using function SetFindMask it is possible to specify a combination of attributes that the drives to be searched must match. |
0 | 458 |
|
459 |
Notes: |
|
460 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
1. The function sets aDir to NULL, then allocates memory for it before appending entries to the list. Therefore, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
462 |
aDir should have no memory allocated to it before this function is called, otherwise this memory will become orphaned. |
0 | 463 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
464 |
2. The caller of the function is responsible for deleting aDir after the function has returned. On error this pointer will be set NULL, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
465 |
thus safe to delete. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
466 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
467 |
3. Calling TFindFile::File() after a successful search gets the drive letter and directory containing the file(s). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
468 |
The filenames can be retrieved via the array of TEntry::iName objects contained in aDir. If you want to retrieve the fully |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
469 |
qualified path of a file, you need to parse the path and the filename. |
0 | 470 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
471 |
@param aFileName The filename to search for. May contain wildcards. If it specifies a directory as well as a filename, then that |
0 | 472 |
directory is searched first. |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
473 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
474 |
@param aPath List of directories to search. Paths in this list must be separated by a semicolon character, but a semicolon is not |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
475 |
required after the final path. The directories are searched in the order in which they occur in the list. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
476 |
Directories must be fully qualified, including a drive letter, and the name must end with a backslash. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
477 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
478 |
@param aDir in: a reference to the pointer that will be modified by this method. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
479 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
480 |
out: On success a pointer to the internally allocated by this method CDir object, which in turn contains the entries for |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
481 |
all files matching aFileName in the first directory in which a match occurred. In this case this API caller is responsible |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
482 |
for deleting aDir. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
If some error occured (including KErrNotFound meaning that nothing found) this pointer will be set to NULL, which is also safe to delete. |
0 | 484 |
|
485 |
@return KErrNone, if one or more matching files was found; |
|
486 |
KErrNotFound, if no matching file was found in any of the directories. |
|
487 |
KErrArgument, if the filename is empty. |
|
488 |
||
489 |
@see TFindFile::FindWild |
|
490 |
@see TFindFile::File |
|
491 |
@see TEntry::iName |
|
492 |
@see TFindFile::SetFindMask() |
|
493 |
*/ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
494 |
EXPORT_C TInt TFindFile::FindWildByPath(const TDesC& aFileName,const TDesC* aPath,CDir*& aDir) |
0 | 495 |
{ |
496 |
||
497 |
iDir=&aDir; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
*iDir=NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
499 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
500 |
return CallSafe(DoFindByPath(aFileName,aPath)); |
0 | 501 |
} |
502 |
||
503 |
||
504 |
||
505 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
506 |
|
0 | 507 |
/** |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
508 |
Searches, using wildcards, for one or more files/directories in a specified directory. |
0 | 509 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
If no matching file is found in that directory, all available drives are searched in descending alphabetical order, from Y: to A:, and ending |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
511 |
with the Z: drive.Using function SetFindMask it is possible to specify a combination of attributes that the drives to be searched must match. |
0 | 512 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
513 |
The search ends when one or more matching filenames are found, or when every available drive has been unsuccessfully searched. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
514 |
To begin searching again after a successful match has been made, use FindWild(). Wildcards may be specified in the filename. |
0 | 515 |
|
516 |
Notes: |
|
517 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
518 |
1. A drive letter may be specified in aDirPath (or in aFileName). If a drive is specified, that drive is searched first, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
519 |
followed by the other available drives, in descending alphabetical order. If no drive is specified, the drive contained in the session |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
520 |
path is searched first. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
521 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
522 |
2. The function sets aDir to NULL, then allocates memory for it before appending entries to the list. Therefore, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
523 |
aDir should have no memory allocated to it before this function is called, otherwise this memory will become orphaned. |
0 | 524 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
525 |
3. The caller of the function is responsible for deleting aDir after the function has returned. On error this pointer will be set NULL, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
526 |
thus safe to delete. |
0 | 527 |
|
528 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
529 |
4. Calling TFindFile::File() after a successful search returns the drive letter and directory containing the file(s). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
530 |
Filenames may be retrieved via the array of TEntry::iNames contained in aDir. If you want to retrieve the fully |
0 | 531 |
qualified path of a file, you will need to parse the path and the filename. |
532 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
533 |
@param aFileName The filename to search for. May contain wildcards. If a path is specified, it overrides the path specified in aDirPath. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
534 |
If no path is specified, the path contained in aDirPath is used in the search. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
535 |
|
0 | 536 |
@param aDirPath Path indicating a directory to search on each drive. |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
537 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
538 |
@param aDir in: a reference to the pointer that will be modified by this method. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
539 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
540 |
out: On success a pointer to the internally allocated by this method CDir object, which in turn contains the entries for |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
541 |
all files matching aFileName in the first directory in which a match occurred. In this case this API caller is responsible |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
542 |
for deleting aDir. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
543 |
If some error occured (including KErrNotFound meaning that nothing found) this pointer will be set to NULL, which is also safe to delete. |
0 | 544 |
|
545 |
@return KErrNone if one or more matching files was found; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
546 |
KErrNotFound if no matching file was found in the directory on any of the drives. |
0 | 547 |
KErrArgument, if the filename is empty. |
548 |
||
549 |
@see TFindFile::FindWild |
|
550 |
@see TFindFile::File |
|
551 |
@see TFindFile::SetFindMask() |
|
552 |
*/ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
553 |
EXPORT_C TInt TFindFile::FindWildByDir(const TDesC& aFileName,const TDesC& aDirPath,CDir*& aDir) |
0 | 554 |
{ |
555 |
iDir=&aDir; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
556 |
*iDir=NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
557 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
558 |
return CallSafe(DoFindByDir(aFileName,aDirPath)); |
0 | 559 |
} |
560 |
||
561 |
||
562 |
||
563 |
||
564 |
// |
|
565 |
// Find the next match |
|
566 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
567 |
TInt TFindFile::DoFind() |
0 | 568 |
{ |
569 |
||
570 |
TInt ret=KErrNone; |
|
571 |
switch(iMode) |
|
572 |
{ |
|
573 |
case EFindByDrives: |
|
574 |
ret=DoFindNextInDriveList(); |
|
575 |
break; |
|
576 |
case EFindByPath: |
|
577 |
case EFindByDrivesInPath: |
|
578 |
ret=DoFindNextInPath(); |
|
579 |
break; |
|
580 |
default: |
|
581 |
Panic(EFindFileIllegalMode); |
|
582 |
} |
|
583 |
return(ret); |
|
584 |
} |
|
585 |
||
586 |
||
587 |
||
588 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
589 |
|
0 | 590 |
/** |
591 |
Searches for the next file/directory. |
|
592 |
||
593 |
This should be used after a successful call to FindByPath() or FindByDir(), |
|
594 |
to find the next occurrence of the filename in the path or drive list. |
|
595 |
||
596 |
Using function SetFindMask it is possible to specify a combination of |
|
597 |
attributes that the drives to be searched must match. |
|
598 |
||
599 |
Note: |
|
600 |
||
601 |
1. After a file/directory has been found, use TFindFile::File() to get the |
|
602 |
fully qualified path and filename. |
|
603 |
||
604 |
@return KErrNone, if another occurrence of the file was found; |
|
605 |
KErrNotFound, if no more occurrences were found. |
|
606 |
||
607 |
@see TFindFile::FindByPath |
|
608 |
@see TFindFile::FindByDir |
|
609 |
@see TFindFile::File |
|
610 |
@see TFindFile::SetFindMask() |
|
611 |
||
612 |
*/ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
613 |
EXPORT_C TInt TFindFile::Find() |
0 | 614 |
{ |
615 |
||
616 |
// iDir=NULL; |
|
617 |
return(DoFind()); |
|
618 |
} |
|
619 |
||
620 |
||
621 |
||
622 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
623 |
|
0 | 624 |
/** |
625 |
Searches for the next file/directory. |
|
626 |
||
627 |
This should be used after a successful call to FindWildByPath() |
|
628 |
or FindWildByDir(), for the next occurrences of the filename in the |
|
629 |
path or drive list.Using function SetFindMask it is possible to specify a |
|
630 |
combination of attributes that the drives to be searched must match. |
|
631 |
||
632 |
Notes: |
|
633 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
634 |
1. The function sets aDir to NULL, then allocates memory for it before appending entries to the list. Therefore, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
635 |
aDir should have no memory allocated to it before this function is called, otherwise this memory will become orphaned. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
636 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
637 |
2. The caller of the function is responsible for deleting aDir after the function has returned. On error this pointer will be set NULL, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
638 |
thus safe to delete. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
639 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
640 |
3. Calling TFindFile::File() after a successful search, will return the drive letter and the directory containing the file(s). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
641 |
The filenames may be retrieved via the array of TEntry::iName objects contained in aDir. If you want to retrieve the fully qualified |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
642 |
path of a file, you will need to parse the path and the filename using the TParse class or derived classes. |
0 | 643 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
644 |
@param aDir in: a reference to the pointer that will be modified by this method. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
645 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
646 |
out: On success a pointer to the internally allocated by this method CDir object, which in turn contains the entries for |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
647 |
all files matching aFileName in the first directory in which a match occurred. In this case this API caller is responsible |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
648 |
for deleting aDir. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
649 |
If some error occured (including KErrNotFound meaning that nothing found) this pointer will be set to NULL, which is also safe to delete. |
0 | 650 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
651 |
@return KErrNone if further occurrences were found; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
652 |
KErrNotFound if no more matching files were found. |
0 | 653 |
|
654 |
||
655 |
@see TParse |
|
656 |
@see TEntry::iName |
|
657 |
@see TFindFile::File |
|
658 |
@see TFindFile::FindWildByPath |
|
659 |
@see TFindFile::FindWildByDir |
|
660 |
@see TFindFile::SetFindMask() |
|
661 |
*/ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
662 |
EXPORT_C TInt TFindFile::FindWild(CDir*& aDir) |
0 | 663 |
{ |
664 |
||
665 |
iDir=&aDir; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
666 |
*iDir=NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
667 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
668 |
return CallSafe(DoFind()); |
0 | 669 |
} |
670 |
||
671 |
||
672 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
673 |
|
0 | 674 |
/** |
675 |
Can be used in order to specify a combination of drive attributes that the drives |
|
676 |
to be searched must match. When searching without specifying a mask, all drives, except the |
|
677 |
remote ones will be returned. |
|
678 |
||
679 |
@param aMask The combination of drive attributes that we want the drives to match. |
|
680 |
||
681 |
@return KErrNone, if the mask supplied is correct. |
|
682 |
KErrArgument, if the mask supplied is invalid. |
|
683 |
*/ |
|
684 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
685 |
EXPORT_C TInt TFindFile::SetFindMask(TUint aMask) |
0 | 686 |
{ |
687 |
TInt r =ValidateMatchMask(aMask); |
|
688 |
if(r!=KErrNone) |
|
689 |
return r; |
|
690 |
else |
|
691 |
{ |
|
692 |
if(aMask != 0) |
|
693 |
iMatchMask = aMask; |
|
694 |
else |
|
695 |
iMatchMask = (KDriveAttExclude |KDriveAttMatchedFlags) ; //KDriveAttMatchedFlags ==0xFF so this exclude all drives in DoFindNextInDriveList |
|
696 |
||
697 |
return KErrNone; |
|
698 |
||
699 |
} |
|
700 |
} |
|
701 |