sl@0
|
1 |
// Copyright (c) 1995-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 the License "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 <f32file.h>
|
sl@0
|
17 |
#include <e32test.h>
|
sl@0
|
18 |
#include "t_server.h"
|
sl@0
|
19 |
|
sl@0
|
20 |
GLDEF_D RTest test(_L("T_GDIR"));
|
sl@0
|
21 |
|
sl@0
|
22 |
LOCAL_D const TInt KFilesMax=9;
|
sl@0
|
23 |
LOCAL_D const TInt KUidFilesMax=7;
|
sl@0
|
24 |
LOCAL_D const TInt KDirsMax=4;
|
sl@0
|
25 |
LOCAL_D TBool gFirstRun=ETrue;
|
sl@0
|
26 |
LOCAL_D TPtrC test_dir(_L("\\F32-TST\\GDIR\\"));
|
sl@0
|
27 |
LOCAL_D TPtrC test_dir_1(_L("\\F32-TST\\GDIR\\*"));
|
sl@0
|
28 |
|
sl@0
|
29 |
class TUidFile
|
sl@0
|
30 |
{
|
sl@0
|
31 |
public:
|
sl@0
|
32 |
TUidFile(const TText* aFileName,TUidType aUidType,const TText8* aContents);
|
sl@0
|
33 |
public:
|
sl@0
|
34 |
const TText* iFileName;
|
sl@0
|
35 |
TUidType iUidType;
|
sl@0
|
36 |
const TText8* iContents;
|
sl@0
|
37 |
};
|
sl@0
|
38 |
|
sl@0
|
39 |
TUidFile::TUidFile(const TText* aFileName,TUidType aUidType,const TText8* aContents)
|
sl@0
|
40 |
: iFileName(aFileName), iUidType(aUidType), iContents(aContents)
|
sl@0
|
41 |
{}
|
sl@0
|
42 |
|
sl@0
|
43 |
LOCAL_D TUidFile uidFiles[] =
|
sl@0
|
44 |
{
|
sl@0
|
45 |
TUidFile(_S("File1.TXT"), TUidType(TUid::Uid(1),TUid::Uid(2),TUid::Uid(731)),_S8("blarg blarg blarg")),
|
sl@0
|
46 |
TUidFile(_S("asdf.asdf"), TUidType(TUid::Uid(55),TUid::Uid(2),TUid::Uid(731)),_S8("blarg")),
|
sl@0
|
47 |
TUidFile(_S("another fiel"), TUidType(TUid::Uid(104),TUid::Uid(22),TUid::Uid(731)),_S8("blarg2")),
|
sl@0
|
48 |
TUidFile(_S("another fiel1"), TUidType(TUid::Uid(7),TUid::Uid(23),TUid::Uid(131)),_S8("")),
|
sl@0
|
49 |
TUidFile(_S("another fiel2"), TUidType(TUid::Uid(8),TUid::Uid(2),TUid::Uid(531)),_S8("asdf")),
|
sl@0
|
50 |
TUidFile(_S("another fiel3"), TUidType(TUid::Uid(9),TUid::Uid(22),TUid::Uid(531)),_S8("blar")),
|
sl@0
|
51 |
TUidFile(_S("another fiel4"), TUidType(TUid::Uid(10),TUid::Uid(23),TUid::Uid(231)),_S8("blarg blarg blarg asdlfjasdfasdfasdfasdfasdfadfafa"))
|
sl@0
|
52 |
};
|
sl@0
|
53 |
|
sl@0
|
54 |
LOCAL_D const TText* fileNames[] =
|
sl@0
|
55 |
{
|
sl@0
|
56 |
_S("B1.B3"),_S("B2.B2"),_S("B3.B1"),
|
sl@0
|
57 |
_S("A1.A3"),_S("A2.A2"),_S("A3.A1"),
|
sl@0
|
58 |
_S("Z1.Z3"),_S("Z2.Z2"),_S("Z3.Z1")
|
sl@0
|
59 |
};
|
sl@0
|
60 |
|
sl@0
|
61 |
LOCAL_D const TText* dirNames[] =
|
sl@0
|
62 |
{
|
sl@0
|
63 |
_S("DB1"),
|
sl@0
|
64 |
_S("DA1"),
|
sl@0
|
65 |
_S("DZ1"),
|
sl@0
|
66 |
_S("DD1")
|
sl@0
|
67 |
};
|
sl@0
|
68 |
|
sl@0
|
69 |
inline TName files(TInt anIndex)
|
sl@0
|
70 |
{return(TName(fileNames[anIndex]));}
|
sl@0
|
71 |
inline TName dirs(TInt anIndex)
|
sl@0
|
72 |
{return(TName(dirNames[anIndex]));}
|
sl@0
|
73 |
|
sl@0
|
74 |
LOCAL_C void displayDir(const CDir& aDir,TInt& aDirCount,TInt& aFileCount)
|
sl@0
|
75 |
//
|
sl@0
|
76 |
// Display the contents of a directory list.
|
sl@0
|
77 |
//
|
sl@0
|
78 |
{
|
sl@0
|
79 |
|
sl@0
|
80 |
TInt count=aDir.Count();
|
sl@0
|
81 |
TInt i=0;
|
sl@0
|
82 |
TInt fCount=0;
|
sl@0
|
83 |
TInt dCount=0;
|
sl@0
|
84 |
while (i<count)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
const TEntry& e=aDir[i++];
|
sl@0
|
87 |
if (e.IsDir())
|
sl@0
|
88 |
{
|
sl@0
|
89 |
dCount++;
|
sl@0
|
90 |
test.Printf(_L("%- 16S <DIR>\n"),&e.iName);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
else
|
sl@0
|
93 |
{
|
sl@0
|
94 |
fCount++;
|
sl@0
|
95 |
test.Printf(_L("%- 16S %+ 8d\n"),&e.iName,e.iSize);
|
sl@0
|
96 |
}
|
sl@0
|
97 |
}
|
sl@0
|
98 |
test.Printf(_L("Dirs = %d Files = %d\n"),dCount,fCount);
|
sl@0
|
99 |
aFileCount=fCount;
|
sl@0
|
100 |
aDirCount=dCount;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
LOCAL_C void createFile(const TUidFile& aFileName)
|
sl@0
|
104 |
//
|
sl@0
|
105 |
// Create a file in the test directory.
|
sl@0
|
106 |
//
|
sl@0
|
107 |
{
|
sl@0
|
108 |
|
sl@0
|
109 |
TCheckedUid checkedUid(aFileName.iUidType);
|
sl@0
|
110 |
TPtrC fileName(aFileName.iFileName);
|
sl@0
|
111 |
TAutoClose<RFile> file;
|
sl@0
|
112 |
TInt r=file.iObj.Replace(TheFs,fileName,EFileWrite);
|
sl@0
|
113 |
test(r==KErrNone);
|
sl@0
|
114 |
TPtrC8 uidBuf((TUint8*)&checkedUid,sizeof(TCheckedUid));
|
sl@0
|
115 |
r=file.iObj.Write(uidBuf);
|
sl@0
|
116 |
test(r==KErrNone);
|
sl@0
|
117 |
TPtrC8 contents(aFileName.iContents);
|
sl@0
|
118 |
r=file.iObj.Write(contents);
|
sl@0
|
119 |
test(r==KErrNone);
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
LOCAL_C void createFile(TInt anIndex)
|
sl@0
|
123 |
//
|
sl@0
|
124 |
// Create a file in the test directory.
|
sl@0
|
125 |
//
|
sl@0
|
126 |
{
|
sl@0
|
127 |
|
sl@0
|
128 |
TFileName fName;
|
sl@0
|
129 |
TName name=files(anIndex);
|
sl@0
|
130 |
fName.Format(_L("%S%S"),&test_dir,&name);
|
sl@0
|
131 |
TBuf<0x80> mes;
|
sl@0
|
132 |
mes.Format(_L("Create file %S"),&fName);
|
sl@0
|
133 |
test.Next(mes);
|
sl@0
|
134 |
//
|
sl@0
|
135 |
TAutoClose<RFile> file;
|
sl@0
|
136 |
TInt r=file.iObj.Replace(TheFs,fName,EFileWrite);
|
sl@0
|
137 |
test(r==KErrNone);
|
sl@0
|
138 |
TBuf8<36> b((TUint8*)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
sl@0
|
139 |
b.SetLength(anIndex+1);
|
sl@0
|
140 |
r=file.iObj.Write(b);
|
sl@0
|
141 |
test(r==KErrNone);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
LOCAL_C void createDir(TInt anIndex)
|
sl@0
|
145 |
//
|
sl@0
|
146 |
// Create a dir in the test directory.
|
sl@0
|
147 |
//
|
sl@0
|
148 |
{
|
sl@0
|
149 |
|
sl@0
|
150 |
TFileName dName;
|
sl@0
|
151 |
TName name=dirs(anIndex);
|
sl@0
|
152 |
dName.Format(_L("%S%S\\"),&test_dir,&name);
|
sl@0
|
153 |
TBuf<0x80> mes;
|
sl@0
|
154 |
mes.Format(_L("Create dir %S"),&dName);
|
sl@0
|
155 |
test.Next(mes);
|
sl@0
|
156 |
//
|
sl@0
|
157 |
TInt r=TheFs.MkDir(dName);
|
sl@0
|
158 |
test(r==KErrNone);
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
LOCAL_C void testSetup()
|
sl@0
|
162 |
//
|
sl@0
|
163 |
// Setup the test environment.
|
sl@0
|
164 |
//
|
sl@0
|
165 |
{
|
sl@0
|
166 |
|
sl@0
|
167 |
test.Next(_L("Remove test directory"));
|
sl@0
|
168 |
CDir* pD;
|
sl@0
|
169 |
TInt r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,EDirsLast,pD);
|
sl@0
|
170 |
test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound);
|
sl@0
|
171 |
if (r==KErrNone)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
TInt count=pD->Count();
|
sl@0
|
174 |
TInt i=0;
|
sl@0
|
175 |
while (i<count)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
const TEntry& e=(*pD)[i++];
|
sl@0
|
178 |
if (e.IsDir())
|
sl@0
|
179 |
{
|
sl@0
|
180 |
TFileName name;
|
sl@0
|
181 |
name.Format(_L("%S%S\\"),&test_dir,&e.iName);
|
sl@0
|
182 |
r=TheFs.RmDir(name);
|
sl@0
|
183 |
test(r==KErrNone);
|
sl@0
|
184 |
}
|
sl@0
|
185 |
else
|
sl@0
|
186 |
{
|
sl@0
|
187 |
TFileName name;
|
sl@0
|
188 |
name.Format(_L("%S%S"),&test_dir,&e.iName);
|
sl@0
|
189 |
r=TheFs.Delete(name);
|
sl@0
|
190 |
test(r==KErrNone);
|
sl@0
|
191 |
}
|
sl@0
|
192 |
}
|
sl@0
|
193 |
}
|
sl@0
|
194 |
//
|
sl@0
|
195 |
delete pD;
|
sl@0
|
196 |
//
|
sl@0
|
197 |
test.Next(_L("Create test files"));
|
sl@0
|
198 |
TInt i=0;
|
sl@0
|
199 |
while (i<KFilesMax)
|
sl@0
|
200 |
createFile(i++);
|
sl@0
|
201 |
//
|
sl@0
|
202 |
test.Next(_L("Create test directories"));
|
sl@0
|
203 |
i=0;
|
sl@0
|
204 |
while (i<KDirsMax)
|
sl@0
|
205 |
createDir(i++);
|
sl@0
|
206 |
}
|
sl@0
|
207 |
|
sl@0
|
208 |
LOCAL_C void testDir()
|
sl@0
|
209 |
//
|
sl@0
|
210 |
// Setup the test environment.
|
sl@0
|
211 |
//
|
sl@0
|
212 |
{
|
sl@0
|
213 |
|
sl@0
|
214 |
TInt dCount;
|
sl@0
|
215 |
TInt fCount;
|
sl@0
|
216 |
test.Next(_L("Test directory handling"));
|
sl@0
|
217 |
CDir* pD;
|
sl@0
|
218 |
TInt r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,EDirsLast,pD);
|
sl@0
|
219 |
test(r==KErrNone);
|
sl@0
|
220 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
221 |
test(dCount==4 && fCount==9);
|
sl@0
|
222 |
delete pD;
|
sl@0
|
223 |
//
|
sl@0
|
224 |
test.Next(_L("Attributes: NULL"));
|
sl@0
|
225 |
r=TheFs.GetDir(test_dir_1,NULL,EDirsLast,pD);
|
sl@0
|
226 |
test(r==KErrNone);
|
sl@0
|
227 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
228 |
test(dCount==0 && fCount==9);
|
sl@0
|
229 |
delete pD;
|
sl@0
|
230 |
//
|
sl@0
|
231 |
test.Next(_L("Attributes: KEntryAttDir & EDescending sort"));
|
sl@0
|
232 |
r=TheFs.GetDir(test_dir_1,KEntryAttDir,ESortByName|EDescending,pD);
|
sl@0
|
233 |
test(r==KErrNone);
|
sl@0
|
234 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
235 |
test(dCount==4 && fCount==9);
|
sl@0
|
236 |
delete pD;
|
sl@0
|
237 |
//
|
sl@0
|
238 |
test.Next(_L("Attributes: Excl,Dir"));
|
sl@0
|
239 |
r=TheFs.GetDir(test_dir_1,KEntryAttMatchExclusive|KEntryAttDir,ESortByName|EDescending,pD);
|
sl@0
|
240 |
test(r==KErrNone);
|
sl@0
|
241 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
242 |
test(dCount==4 && fCount==0);
|
sl@0
|
243 |
delete pD;
|
sl@0
|
244 |
//
|
sl@0
|
245 |
CDir* pD2;
|
sl@0
|
246 |
//
|
sl@0
|
247 |
test.Next(_L("Test split directories and files"));
|
sl@0
|
248 |
r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,ESortByName,pD,pD2);
|
sl@0
|
249 |
test(r==KErrNone);
|
sl@0
|
250 |
test.Printf(_L("FileList:\n"));
|
sl@0
|
251 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
252 |
test(dCount==4 && fCount==9);
|
sl@0
|
253 |
test.Printf(_L("DirList:\n"));
|
sl@0
|
254 |
displayDir(*pD2,dCount,fCount);
|
sl@0
|
255 |
test(dCount==4 && fCount==0);
|
sl@0
|
256 |
delete pD;
|
sl@0
|
257 |
delete pD2;
|
sl@0
|
258 |
//
|
sl@0
|
259 |
test.Next(_L("Attributes: NULL"));
|
sl@0
|
260 |
r=TheFs.GetDir(test_dir_1,NULL,ESortByName,pD,pD2);
|
sl@0
|
261 |
test(r==KErrNone);
|
sl@0
|
262 |
test.Printf(_L("FileList:\n"));
|
sl@0
|
263 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
264 |
test(dCount==0 && fCount==9);
|
sl@0
|
265 |
test.Printf(_L("DirList:\n"));
|
sl@0
|
266 |
displayDir(*pD2,dCount,fCount);
|
sl@0
|
267 |
test(dCount==4 && fCount==0);
|
sl@0
|
268 |
delete pD;
|
sl@0
|
269 |
delete pD2;
|
sl@0
|
270 |
//
|
sl@0
|
271 |
test.Next(_L("Attributes: KEntryAttDir"));
|
sl@0
|
272 |
r=TheFs.GetDir(test_dir_1,KEntryAttDir,ESortByName,pD,pD2);
|
sl@0
|
273 |
test(r==KErrNone);
|
sl@0
|
274 |
test.Printf(_L("FileList:\n"));
|
sl@0
|
275 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
276 |
test(dCount==4 && fCount==9);
|
sl@0
|
277 |
test.Printf(_L("DirList:\n"));
|
sl@0
|
278 |
displayDir(*pD2,dCount,fCount);
|
sl@0
|
279 |
test(dCount==4 && fCount==0);
|
sl@0
|
280 |
delete pD;
|
sl@0
|
281 |
delete pD2;
|
sl@0
|
282 |
//
|
sl@0
|
283 |
test.Next(_L("Attributes: Excl,Dir"));
|
sl@0
|
284 |
r=TheFs.GetDir(test_dir_1,KEntryAttMatchExclusive|KEntryAttDir,ESortByName,pD,pD2);
|
sl@0
|
285 |
test(r==KErrNone);
|
sl@0
|
286 |
test.Printf(_L("FileList:\n"));
|
sl@0
|
287 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
288 |
test(dCount==4 && fCount==0);
|
sl@0
|
289 |
test.Printf(_L("DirList:\n"));
|
sl@0
|
290 |
displayDir(*pD2,dCount,fCount);
|
sl@0
|
291 |
test(dCount==4 && fCount==0);
|
sl@0
|
292 |
delete pD;
|
sl@0
|
293 |
delete pD2;
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
LOCAL_C void testZDirectory()
|
sl@0
|
297 |
//
|
sl@0
|
298 |
// Display Z directory
|
sl@0
|
299 |
//
|
sl@0
|
300 |
{
|
sl@0
|
301 |
|
sl@0
|
302 |
test.Next(_L("Test Z:"));
|
sl@0
|
303 |
TInt dCount,fCount;
|
sl@0
|
304 |
CDir* pD;
|
sl@0
|
305 |
TInt r=TheFs.GetDir(_L("Z:\\*"),KEntryAttMaskSupported,EDirsFirst,pD);
|
sl@0
|
306 |
test(r==KErrNone);
|
sl@0
|
307 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
308 |
delete pD;
|
sl@0
|
309 |
}
|
sl@0
|
310 |
|
sl@0
|
311 |
LOCAL_C void testDisplayFiles()
|
sl@0
|
312 |
//
|
sl@0
|
313 |
// Display some files
|
sl@0
|
314 |
//
|
sl@0
|
315 |
{
|
sl@0
|
316 |
|
sl@0
|
317 |
test.Next(_L("Display contents of current directory"));
|
sl@0
|
318 |
CDir* pD;
|
sl@0
|
319 |
TInt r=TheFs.GetDir(gSessionPath,KEntryAttMaskSupported,EDirsFirst,pD);
|
sl@0
|
320 |
test(r==KErrNone);
|
sl@0
|
321 |
TInt dCount,fCount;
|
sl@0
|
322 |
displayDir(*pD,dCount,fCount);
|
sl@0
|
323 |
delete pD;
|
sl@0
|
324 |
|
sl@0
|
325 |
TParsePtrC session(gSessionPath);
|
sl@0
|
326 |
TParse parser;
|
sl@0
|
327 |
TBuf<16> noName=_L("asdf.idd");
|
sl@0
|
328 |
parser.Set(session.Drive(),&noName,NULL);
|
sl@0
|
329 |
r=TheFs.GetDir(parser.FullName(),KEntryAttMaskSupported,EDirsFirst,pD);
|
sl@0
|
330 |
test(r==KErrNone);
|
sl@0
|
331 |
test(pD->Count()==0);
|
sl@0
|
332 |
delete pD;
|
sl@0
|
333 |
}
|
sl@0
|
334 |
|
sl@0
|
335 |
LOCAL_C void MatchUidFile(TInt aUidFile,TInt anEntryNum,const CDir* aFileList)
|
sl@0
|
336 |
//
|
sl@0
|
337 |
// Check aUidFile matches anEntryNum
|
sl@0
|
338 |
//
|
sl@0
|
339 |
{
|
sl@0
|
340 |
|
sl@0
|
341 |
test(aUidFile<KUidFilesMax);
|
sl@0
|
342 |
TInt count=aFileList->Count();
|
sl@0
|
343 |
test(anEntryNum<count);
|
sl@0
|
344 |
TEntry entry=(*aFileList)[anEntryNum];
|
sl@0
|
345 |
|
sl@0
|
346 |
TPtrC uidFileName(uidFiles[aUidFile].iFileName);
|
sl@0
|
347 |
test(entry.iName==uidFileName);
|
sl@0
|
348 |
test(entry.iType==uidFiles[aUidFile].iUidType);
|
sl@0
|
349 |
|
sl@0
|
350 |
RFile f;
|
sl@0
|
351 |
TInt r=f.Open(TheFs,entry.iName,EFileRead);
|
sl@0
|
352 |
test(r==KErrNone);
|
sl@0
|
353 |
TBuf8<256> contents;
|
sl@0
|
354 |
r=f.Read(sizeof(TCheckedUid),contents);
|
sl@0
|
355 |
test(r==KErrNone);
|
sl@0
|
356 |
TPtrC8 uidFileContents(uidFiles[aUidFile].iContents);
|
sl@0
|
357 |
test(contents==uidFileContents);
|
sl@0
|
358 |
r=f.Read(contents);
|
sl@0
|
359 |
test(r==KErrNone);
|
sl@0
|
360 |
test(contents.Length()==0);
|
sl@0
|
361 |
f.Close();
|
sl@0
|
362 |
}
|
sl@0
|
363 |
|
sl@0
|
364 |
LOCAL_C TInt PrintUid(TInt anEntryNum,const CDir* aFileList)
|
sl@0
|
365 |
//
|
sl@0
|
366 |
// Check aUidFile matches anEntryNum
|
sl@0
|
367 |
//
|
sl@0
|
368 |
{
|
sl@0
|
369 |
|
sl@0
|
370 |
TInt count=aFileList->Count();
|
sl@0
|
371 |
test(anEntryNum<count);
|
sl@0
|
372 |
TEntry entry=(*aFileList)[anEntryNum];
|
sl@0
|
373 |
test.Printf(_L("Entry name = %S UID=%d\n"),&entry.iName,entry.iType[2]);
|
sl@0
|
374 |
return(entry.iType[2].iUid);
|
sl@0
|
375 |
}
|
sl@0
|
376 |
|
sl@0
|
377 |
LOCAL_C void testGetDirByUid()
|
sl@0
|
378 |
//
|
sl@0
|
379 |
// Get directory contents by matching UIDs
|
sl@0
|
380 |
//
|
sl@0
|
381 |
{
|
sl@0
|
382 |
|
sl@0
|
383 |
test.Next(_L("Get directory contents by matching UIDs"));
|
sl@0
|
384 |
TInt i=KUidFilesMax;
|
sl@0
|
385 |
while(i--)
|
sl@0
|
386 |
createFile(uidFiles[i]);
|
sl@0
|
387 |
|
sl@0
|
388 |
TBuf<16> matchName=_L("*.txt");
|
sl@0
|
389 |
TUidType matchUid(TUid::Null(),TUid::Uid(2),TUid::Null());
|
sl@0
|
390 |
CDir* fileList;
|
sl@0
|
391 |
TInt r=TheFs.GetDir(matchName,matchUid,EAscending,fileList);
|
sl@0
|
392 |
test(r==KErrNone);
|
sl@0
|
393 |
TInt count=fileList->Count();
|
sl@0
|
394 |
test(count==1);
|
sl@0
|
395 |
MatchUidFile(0,0,fileList);
|
sl@0
|
396 |
delete fileList;
|
sl@0
|
397 |
|
sl@0
|
398 |
matchName=_L("*.*");
|
sl@0
|
399 |
matchUid=TUidType(TUid::Uid(1),TUid::Uid(2),TUid::Uid(731));
|
sl@0
|
400 |
r=TheFs.GetDir(matchName,matchUid,EAscending,fileList);
|
sl@0
|
401 |
test(r==KErrNone);
|
sl@0
|
402 |
count=fileList->Count();
|
sl@0
|
403 |
test(count==1);
|
sl@0
|
404 |
MatchUidFile(0,0,fileList);
|
sl@0
|
405 |
delete fileList;
|
sl@0
|
406 |
|
sl@0
|
407 |
matchName=_L("*.*");
|
sl@0
|
408 |
matchUid=TUidType(TUid::Null(),TUid::Uid(2),TUid::Null());
|
sl@0
|
409 |
r=TheFs.GetDir(matchName,matchUid,ESortByName|EAscending,fileList);
|
sl@0
|
410 |
test(r==KErrNone);
|
sl@0
|
411 |
count=fileList->Count();
|
sl@0
|
412 |
test(count==3);
|
sl@0
|
413 |
MatchUidFile(0,2,fileList);
|
sl@0
|
414 |
MatchUidFile(1,1,fileList);
|
sl@0
|
415 |
MatchUidFile(4,0,fileList);
|
sl@0
|
416 |
delete fileList;
|
sl@0
|
417 |
|
sl@0
|
418 |
matchName=_L("*.*");
|
sl@0
|
419 |
matchUid=TUidType(TUid::Null(),TUid::Null(),TUid::Uid(731));
|
sl@0
|
420 |
r=TheFs.GetDir(matchName,matchUid,ESortByName|EAscending,fileList);
|
sl@0
|
421 |
test(r==KErrNone);
|
sl@0
|
422 |
count=fileList->Count();
|
sl@0
|
423 |
test(count==3);
|
sl@0
|
424 |
MatchUidFile(2,0,fileList);
|
sl@0
|
425 |
MatchUidFile(1,1,fileList);
|
sl@0
|
426 |
MatchUidFile(0,2,fileList);
|
sl@0
|
427 |
delete fileList;
|
sl@0
|
428 |
|
sl@0
|
429 |
matchName=_L("*.*");
|
sl@0
|
430 |
r=TheFs.GetDir(matchName,KEntryAttNormal,ESortByUid|EAscending,fileList);
|
sl@0
|
431 |
test(r==KErrNone);
|
sl@0
|
432 |
count=fileList->Count();
|
sl@0
|
433 |
MatchUidFile(4,0,fileList);
|
sl@0
|
434 |
MatchUidFile(1,1,fileList);
|
sl@0
|
435 |
MatchUidFile(0,2,fileList);
|
sl@0
|
436 |
MatchUidFile(5,3,fileList);
|
sl@0
|
437 |
MatchUidFile(2,4,fileList);
|
sl@0
|
438 |
MatchUidFile(3,5,fileList);
|
sl@0
|
439 |
MatchUidFile(6,6,fileList);
|
sl@0
|
440 |
for (i=7;i<count;i++)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
TEntry entry;
|
sl@0
|
443 |
entry=(*fileList)[i];
|
sl@0
|
444 |
test(entry.iType[2].iUid==0);
|
sl@0
|
445 |
PrintUid(i,fileList);
|
sl@0
|
446 |
}
|
sl@0
|
447 |
test(i==count);
|
sl@0
|
448 |
delete fileList;
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
LOCAL_C void testZGetDirByUid()
|
sl@0
|
452 |
//
|
sl@0
|
453 |
// Get directory contents by matching UIDs from Z:
|
sl@0
|
454 |
//
|
sl@0
|
455 |
{
|
sl@0
|
456 |
|
sl@0
|
457 |
TUidType matchUid(TUid::Null(),TUid::Uid(0x1000008c),TUid::Null());
|
sl@0
|
458 |
CDir* fileList;
|
sl@0
|
459 |
TInt r=TheFs.GetDir(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("Z:\\SYS\\BIN\\"):_L("Z:\\SYSTEM\\BIN\\"),matchUid,EAscending,fileList);
|
sl@0
|
460 |
test(r==KErrNone);
|
sl@0
|
461 |
TInt count=fileList->Count();
|
sl@0
|
462 |
#if defined(__WINS__)
|
sl@0
|
463 |
test(count==0);
|
sl@0
|
464 |
#else
|
sl@0
|
465 |
test.Printf(_L("Count=%d\n"),count);
|
sl@0
|
466 |
while(count--)
|
sl@0
|
467 |
PrintUid(count,fileList);
|
sl@0
|
468 |
// test(count==1);
|
sl@0
|
469 |
// TEntry entry;
|
sl@0
|
470 |
// entry=(*fileList)[0];
|
sl@0
|
471 |
// test(entry.iName.MatchF(_L("EFILE.EXE"))!=KErrNotFound);
|
sl@0
|
472 |
#endif
|
sl@0
|
473 |
delete fileList;
|
sl@0
|
474 |
}
|
sl@0
|
475 |
|
sl@0
|
476 |
LOCAL_C void testGetFilesExcept()
|
sl@0
|
477 |
//
|
sl@0
|
478 |
// Get all files except read only ...
|
sl@0
|
479 |
//
|
sl@0
|
480 |
{
|
sl@0
|
481 |
|
sl@0
|
482 |
MakeFile(_L("\\F32-TST\\GDIR\\RONLY1.CCC"),KEntryAttReadOnly);
|
sl@0
|
483 |
MakeFile(_L("\\F32-TST\\GDIR\\RONLY2.CCC"),KEntryAttReadOnly);
|
sl@0
|
484 |
MakeFile(_L("\\F32-TST\\GDIR\\RW1.CCC"));
|
sl@0
|
485 |
MakeFile(_L("\\F32-TST\\GDIR\\RW2.CCC"));
|
sl@0
|
486 |
MakeFile(_L("\\F32-TST\\GDIR\\SYSTEM1.CCC"),KEntryAttSystem);
|
sl@0
|
487 |
MakeFile(_L("\\F32-TST\\GDIR\\SYSTEM2.CCC"),KEntryAttSystem);
|
sl@0
|
488 |
|
sl@0
|
489 |
test.Next(_L("Can match only read only files"));
|
sl@0
|
490 |
TUint onlyRO=KEntryAttReadOnly|KEntryAttMatchExclusive;
|
sl@0
|
491 |
CDir* fileList;
|
sl@0
|
492 |
TInt r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),onlyRO,EAscending,fileList);
|
sl@0
|
493 |
test(r==KErrNone);
|
sl@0
|
494 |
TInt count=fileList->Count();
|
sl@0
|
495 |
test(count==2);
|
sl@0
|
496 |
|
sl@0
|
497 |
TEntry entry;
|
sl@0
|
498 |
entry=(*fileList)[0];
|
sl@0
|
499 |
test(entry.iName.MatchF(_L("RONLY1.CCC"))!=KErrNotFound);
|
sl@0
|
500 |
entry=(*fileList)[1];
|
sl@0
|
501 |
test(entry.iName.MatchF(_L("RONLY2.CCC"))!=KErrNotFound);
|
sl@0
|
502 |
delete fileList;
|
sl@0
|
503 |
|
sl@0
|
504 |
test.Next(_L("Can match everything except read only files"));
|
sl@0
|
505 |
TUint excludeRO=KEntryAttReadOnly|KEntryAttMatchExclude;
|
sl@0
|
506 |
r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),excludeRO,EAscending,fileList);
|
sl@0
|
507 |
test(r==KErrNone);
|
sl@0
|
508 |
count=fileList->Count();
|
sl@0
|
509 |
test(count==4);
|
sl@0
|
510 |
|
sl@0
|
511 |
entry=(*fileList)[0];
|
sl@0
|
512 |
test(entry.iName.MatchF(_L("RW1.CCC"))!=KErrNotFound);
|
sl@0
|
513 |
entry=(*fileList)[1];
|
sl@0
|
514 |
test(entry.iName.MatchF(_L("RW2.CCC"))!=KErrNotFound);
|
sl@0
|
515 |
entry=(*fileList)[2];
|
sl@0
|
516 |
test(entry.iName.MatchF(_L("SYSTEM1.CCC"))!=KErrNotFound);
|
sl@0
|
517 |
entry=(*fileList)[3];
|
sl@0
|
518 |
test(entry.iName.MatchF(_L("SYSTEM2.CCC"))!=KErrNotFound);
|
sl@0
|
519 |
delete fileList;
|
sl@0
|
520 |
|
sl@0
|
521 |
test.Next(_L("Can match everything except system and readonly files"));
|
sl@0
|
522 |
TUint excludeSystemAndRO=KEntryAttReadOnly|KEntryAttSystem|KEntryAttMatchExclude;
|
sl@0
|
523 |
r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),excludeSystemAndRO,EAscending,fileList);
|
sl@0
|
524 |
test(r==KErrNone);
|
sl@0
|
525 |
count=fileList->Count();
|
sl@0
|
526 |
test(count==2);
|
sl@0
|
527 |
|
sl@0
|
528 |
entry=(*fileList)[0];
|
sl@0
|
529 |
test(entry.iName.MatchF(_L("RW1.CCC"))!=KErrNotFound);
|
sl@0
|
530 |
entry=(*fileList)[1];
|
sl@0
|
531 |
test(entry.iName.MatchF(_L("RW2.CCC"))!=KErrNotFound);
|
sl@0
|
532 |
delete fileList;
|
sl@0
|
533 |
|
sl@0
|
534 |
r=TheFs.SetAtt(_L("\\F32-TST\\GDIR\\RONLY1.CCC"),0,KEntryAttReadOnly);
|
sl@0
|
535 |
test(r==KErrNone);
|
sl@0
|
536 |
r=TheFs.SetAtt(_L("\\F32-TST\\GDIR\\RONLY2.CCC"),0,KEntryAttReadOnly);
|
sl@0
|
537 |
test(r==KErrNone);
|
sl@0
|
538 |
}
|
sl@0
|
539 |
|
sl@0
|
540 |
LOCAL_C void testGetHidden()
|
sl@0
|
541 |
//
|
sl@0
|
542 |
// Match hidden files and directories
|
sl@0
|
543 |
//
|
sl@0
|
544 |
{
|
sl@0
|
545 |
|
sl@0
|
546 |
test.Next(_L("Match hidden files and directories"));
|
sl@0
|
547 |
MakeFile(_L("File.qqq"));
|
sl@0
|
548 |
MakeFile(_L("FileHidden.qqq"));
|
sl@0
|
549 |
MakeFile(_L("FileSystem.qqq"));
|
sl@0
|
550 |
MakeFile(_L("FileHiddenSystem.qqq"));
|
sl@0
|
551 |
MakeDir(_L("\\F32-TST\\GDIR\\Dir.qqq\\"));
|
sl@0
|
552 |
MakeDir(_L("\\F32-TST\\GDIR\\Dirhidden.qqq\\"));
|
sl@0
|
553 |
MakeDir(_L("\\F32-TST\\GDIR\\Dirsystem.qqq\\"));
|
sl@0
|
554 |
MakeDir(_L("\\F32-TST\\GDIR\\Dirhiddensystem.qqq\\"));
|
sl@0
|
555 |
|
sl@0
|
556 |
TInt r=TheFs.SetAtt(_L("FileHidden.qqq"),KEntryAttHidden,0);
|
sl@0
|
557 |
test(r==KErrNone);
|
sl@0
|
558 |
r=TheFs.SetAtt(_L("Filesystem.qqq"),KEntryAttSystem,0);
|
sl@0
|
559 |
test(r==KErrNone);
|
sl@0
|
560 |
r=TheFs.SetAtt(_L("FilehiddenSystem.qqq"),KEntryAttSystem|KEntryAttHidden,0);
|
sl@0
|
561 |
test(r==KErrNone);
|
sl@0
|
562 |
r=TheFs.SetAtt(_L("dirhidden.qqq"),KEntryAttHidden,0);
|
sl@0
|
563 |
test(r==KErrNone);
|
sl@0
|
564 |
r=TheFs.SetAtt(_L("dirsystem.qqq"),KEntryAttSystem,0);
|
sl@0
|
565 |
test(r==KErrNone);
|
sl@0
|
566 |
r=TheFs.SetAtt(_L("dirhiddensystem.qqq"),KEntryAttSystem|KEntryAttHidden,0);
|
sl@0
|
567 |
test(r==KErrNone);
|
sl@0
|
568 |
|
sl@0
|
569 |
// Files and directories not hidden or system
|
sl@0
|
570 |
CDir* dir;
|
sl@0
|
571 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttDir,ESortByName,dir);
|
sl@0
|
572 |
test(r==KErrNone);
|
sl@0
|
573 |
TInt count=dir->Count();
|
sl@0
|
574 |
test(count==2);
|
sl@0
|
575 |
TEntry entry;
|
sl@0
|
576 |
entry=(*dir)[0];
|
sl@0
|
577 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
|
sl@0
|
578 |
entry=(*dir)[1];
|
sl@0
|
579 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
|
sl@0
|
580 |
delete dir;
|
sl@0
|
581 |
|
sl@0
|
582 |
// Files only
|
sl@0
|
583 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttNormal,ESortByName,dir);
|
sl@0
|
584 |
test(r==KErrNone);
|
sl@0
|
585 |
count=dir->Count();
|
sl@0
|
586 |
test(count==1);
|
sl@0
|
587 |
entry=(*dir)[0];
|
sl@0
|
588 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
|
sl@0
|
589 |
delete dir;
|
sl@0
|
590 |
|
sl@0
|
591 |
// Directories only
|
sl@0
|
592 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir);
|
sl@0
|
593 |
test(r==KErrNone);
|
sl@0
|
594 |
count=dir->Count();
|
sl@0
|
595 |
test(count==1);
|
sl@0
|
596 |
entry=(*dir)[0];
|
sl@0
|
597 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
|
sl@0
|
598 |
delete dir;
|
sl@0
|
599 |
|
sl@0
|
600 |
// Files + hidden
|
sl@0
|
601 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden,ESortByName,dir);
|
sl@0
|
602 |
test(r==KErrNone);
|
sl@0
|
603 |
count=dir->Count();
|
sl@0
|
604 |
test(count==2);
|
sl@0
|
605 |
entry=(*dir)[0];
|
sl@0
|
606 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
|
sl@0
|
607 |
entry=(*dir)[1];
|
sl@0
|
608 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
|
sl@0
|
609 |
delete dir;
|
sl@0
|
610 |
|
sl@0
|
611 |
// Files + system
|
sl@0
|
612 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden,ESortByName,dir);
|
sl@0
|
613 |
test(r==KErrNone);
|
sl@0
|
614 |
count=dir->Count();
|
sl@0
|
615 |
test(count==2);
|
sl@0
|
616 |
entry=(*dir)[0];
|
sl@0
|
617 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
|
sl@0
|
618 |
entry=(*dir)[1];
|
sl@0
|
619 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
|
sl@0
|
620 |
delete dir;
|
sl@0
|
621 |
|
sl@0
|
622 |
// Files + hidden + system
|
sl@0
|
623 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem,ESortByName,dir);
|
sl@0
|
624 |
test(r==KErrNone);
|
sl@0
|
625 |
count=dir->Count();
|
sl@0
|
626 |
test(count==4);
|
sl@0
|
627 |
entry=(*dir)[0];
|
sl@0
|
628 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
|
sl@0
|
629 |
entry=(*dir)[1];
|
sl@0
|
630 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
|
sl@0
|
631 |
entry=(*dir)[2];
|
sl@0
|
632 |
test(entry.iName.MatchF(_L("filehiddensystem.qqq"))!=KErrNotFound);
|
sl@0
|
633 |
entry=(*dir)[3];
|
sl@0
|
634 |
test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound);
|
sl@0
|
635 |
delete dir;
|
sl@0
|
636 |
|
sl@0
|
637 |
// Dirs + hidden
|
sl@0
|
638 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir);
|
sl@0
|
639 |
test(r==KErrNone);
|
sl@0
|
640 |
count=dir->Count();
|
sl@0
|
641 |
test(count==2);
|
sl@0
|
642 |
entry=(*dir)[0];
|
sl@0
|
643 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
|
sl@0
|
644 |
entry=(*dir)[1];
|
sl@0
|
645 |
test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound);
|
sl@0
|
646 |
delete dir;
|
sl@0
|
647 |
|
sl@0
|
648 |
// Dirs + system
|
sl@0
|
649 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttSystem|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir);
|
sl@0
|
650 |
test(r==KErrNone);
|
sl@0
|
651 |
count=dir->Count();
|
sl@0
|
652 |
test(count==2);
|
sl@0
|
653 |
entry=(*dir)[0];
|
sl@0
|
654 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
|
sl@0
|
655 |
entry=(*dir)[1];
|
sl@0
|
656 |
test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound);
|
sl@0
|
657 |
delete dir;
|
sl@0
|
658 |
|
sl@0
|
659 |
// Dirs + hidden + system
|
sl@0
|
660 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir);
|
sl@0
|
661 |
test(r==KErrNone);
|
sl@0
|
662 |
count=dir->Count();
|
sl@0
|
663 |
test(count==4);
|
sl@0
|
664 |
entry=(*dir)[0];
|
sl@0
|
665 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
|
sl@0
|
666 |
entry=(*dir)[1];
|
sl@0
|
667 |
test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound);
|
sl@0
|
668 |
entry=(*dir)[2];
|
sl@0
|
669 |
test(entry.iName.MatchF(_L("dirhiddensystem.qqq"))!=KErrNotFound);
|
sl@0
|
670 |
entry=(*dir)[3];
|
sl@0
|
671 |
test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound);
|
sl@0
|
672 |
|
sl@0
|
673 |
delete dir;
|
sl@0
|
674 |
|
sl@0
|
675 |
// Files + Dirs + hidden
|
sl@0
|
676 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttDir,ESortByName,dir);
|
sl@0
|
677 |
test(r==KErrNone);
|
sl@0
|
678 |
count=dir->Count();
|
sl@0
|
679 |
test(count==4);
|
sl@0
|
680 |
entry=(*dir)[0];
|
sl@0
|
681 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
|
sl@0
|
682 |
entry=(*dir)[1];
|
sl@0
|
683 |
test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound);
|
sl@0
|
684 |
entry=(*dir)[2];
|
sl@0
|
685 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
|
sl@0
|
686 |
entry=(*dir)[3];
|
sl@0
|
687 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
|
sl@0
|
688 |
delete dir;
|
sl@0
|
689 |
|
sl@0
|
690 |
// Files + Dirs + system
|
sl@0
|
691 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttSystem|KEntryAttDir,ESortByName,dir);
|
sl@0
|
692 |
test(r==KErrNone);
|
sl@0
|
693 |
count=dir->Count();
|
sl@0
|
694 |
test(count==4);
|
sl@0
|
695 |
entry=(*dir)[0];
|
sl@0
|
696 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
|
sl@0
|
697 |
entry=(*dir)[1];
|
sl@0
|
698 |
test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound);
|
sl@0
|
699 |
entry=(*dir)[2];
|
sl@0
|
700 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
|
sl@0
|
701 |
entry=(*dir)[3];
|
sl@0
|
702 |
test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound);
|
sl@0
|
703 |
delete dir;
|
sl@0
|
704 |
|
sl@0
|
705 |
// Files + Dirs + hidden + system
|
sl@0
|
706 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem|KEntryAttDir,ESortByName,dir);
|
sl@0
|
707 |
test(r==KErrNone);
|
sl@0
|
708 |
count=dir->Count();
|
sl@0
|
709 |
test(count==8);
|
sl@0
|
710 |
entry=(*dir)[0];
|
sl@0
|
711 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound);
|
sl@0
|
712 |
entry=(*dir)[1];
|
sl@0
|
713 |
test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound);
|
sl@0
|
714 |
entry=(*dir)[2];
|
sl@0
|
715 |
test(entry.iName.MatchF(_L("dirhiddensystem.qqq"))!=KErrNotFound);
|
sl@0
|
716 |
entry=(*dir)[3];
|
sl@0
|
717 |
test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound);
|
sl@0
|
718 |
entry=(*dir)[4];
|
sl@0
|
719 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound);
|
sl@0
|
720 |
entry=(*dir)[5];
|
sl@0
|
721 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound);
|
sl@0
|
722 |
entry=(*dir)[6];
|
sl@0
|
723 |
test(entry.iName.MatchF(_L("filehiddensystem.qqq"))!=KErrNotFound);
|
sl@0
|
724 |
entry=(*dir)[7];
|
sl@0
|
725 |
test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound);
|
sl@0
|
726 |
delete dir;
|
sl@0
|
727 |
}
|
sl@0
|
728 |
|
sl@0
|
729 |
LOCAL_D TFileName gDirDescendingBaseName=_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\");
|
sl@0
|
730 |
LOCAL_D TFileName gDirDescendingEntryName[6]=
|
sl@0
|
731 |
{
|
sl@0
|
732 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\aaaa"),
|
sl@0
|
733 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ssss"),
|
sl@0
|
734 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ZZZZ"),
|
sl@0
|
735 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\aaaa.directory\\"),
|
sl@0
|
736 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\SSSS.dir\\"),
|
sl@0
|
737 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ZZZZDirectory\\")
|
sl@0
|
738 |
};
|
sl@0
|
739 |
|
sl@0
|
740 |
LOCAL_C void TestDirDescendingOrder(const TDesC& aResult,const CDir& aDirList)
|
sl@0
|
741 |
//
|
sl@0
|
742 |
// Test aDirList against aResult
|
sl@0
|
743 |
//
|
sl@0
|
744 |
{
|
sl@0
|
745 |
|
sl@0
|
746 |
TLex lex(aResult);
|
sl@0
|
747 |
TInt count=0;
|
sl@0
|
748 |
while (!lex.Eos())
|
sl@0
|
749 |
{
|
sl@0
|
750 |
lex.Mark();
|
sl@0
|
751 |
while(lex.Get().IsDigit()) {};
|
sl@0
|
752 |
TLex temp(lex.MarkedToken());
|
sl@0
|
753 |
TInt result;
|
sl@0
|
754 |
temp.Val(result);
|
sl@0
|
755 |
TFileName base=gDirDescendingBaseName;
|
sl@0
|
756 |
TEntry entry=aDirList[count];
|
sl@0
|
757 |
base+=entry.iName;
|
sl@0
|
758 |
if (entry.IsDir())
|
sl@0
|
759 |
base+=_L("\\");
|
sl@0
|
760 |
test(base==gDirDescendingEntryName[result]);
|
sl@0
|
761 |
count++;
|
sl@0
|
762 |
}
|
sl@0
|
763 |
}
|
sl@0
|
764 |
|
sl@0
|
765 |
LOCAL_C void testDirDescending()
|
sl@0
|
766 |
//
|
sl@0
|
767 |
// Test EDirDescending
|
sl@0
|
768 |
//
|
sl@0
|
769 |
{
|
sl@0
|
770 |
|
sl@0
|
771 |
test.Next(_L("Test EDirDescending"));
|
sl@0
|
772 |
MakeDir(gDirDescendingBaseName);
|
sl@0
|
773 |
MakeFile(gDirDescendingEntryName[0]);
|
sl@0
|
774 |
MakeFile(gDirDescendingEntryName[1]);
|
sl@0
|
775 |
MakeFile(gDirDescendingEntryName[2]);
|
sl@0
|
776 |
MakeDir(gDirDescendingEntryName[3]);
|
sl@0
|
777 |
MakeDir(gDirDescendingEntryName[4]);
|
sl@0
|
778 |
MakeDir(gDirDescendingEntryName[5]);
|
sl@0
|
779 |
|
sl@0
|
780 |
// Test DirFirst - EDescending
|
sl@0
|
781 |
CDir* dir;
|
sl@0
|
782 |
TUint sortOrder=ESortByName|EDirsFirst|EDescending;
|
sl@0
|
783 |
TInt r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
784 |
test(r==KErrNone);
|
sl@0
|
785 |
// TBuf8<16> result=_L("2,1,0,3,4,5");
|
sl@0
|
786 |
TBuf<16> result=_L("2,1,0,3,4,5");
|
sl@0
|
787 |
|
sl@0
|
788 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
789 |
delete dir;
|
sl@0
|
790 |
// Test DirFirst - EAscending
|
sl@0
|
791 |
sortOrder=ESortByName|EDirsFirst;
|
sl@0
|
792 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
793 |
test(r==KErrNone);
|
sl@0
|
794 |
result=_L("3,4,5,0,1,2");
|
sl@0
|
795 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
796 |
delete dir;
|
sl@0
|
797 |
|
sl@0
|
798 |
// Test DirLast - EDescending
|
sl@0
|
799 |
sortOrder=ESortByName|EDirsLast|EDescending;
|
sl@0
|
800 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
801 |
test(r==KErrNone);
|
sl@0
|
802 |
result=_L("3,4,5,2,1,0");
|
sl@0
|
803 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
804 |
delete dir;
|
sl@0
|
805 |
// Test DirLast - EAscending
|
sl@0
|
806 |
sortOrder=ESortByName|EDirsLast;
|
sl@0
|
807 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
808 |
test(r==KErrNone);
|
sl@0
|
809 |
result=_L("0,1,2,3,4,5");
|
sl@0
|
810 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
811 |
delete dir;
|
sl@0
|
812 |
|
sl@0
|
813 |
// Test DirFirst - EDirDescending
|
sl@0
|
814 |
sortOrder=ESortByName|EDirsFirst|EDirDescending;
|
sl@0
|
815 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
816 |
test(r==KErrNone);
|
sl@0
|
817 |
result=_L("5,4,3,0,1,2");
|
sl@0
|
818 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
819 |
delete dir;
|
sl@0
|
820 |
// Test DirLast - EDirDescending
|
sl@0
|
821 |
sortOrder=ESortByName|EDirsLast|EDirDescending;
|
sl@0
|
822 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
823 |
test(r==KErrNone);
|
sl@0
|
824 |
result=_L("0,1,2,5,4,3");
|
sl@0
|
825 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
826 |
delete dir;
|
sl@0
|
827 |
|
sl@0
|
828 |
// Test DirFirst - EDescending|EDirDescending
|
sl@0
|
829 |
sortOrder=ESortByName|EDirsFirst|EDescending|EDirDescending;
|
sl@0
|
830 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
831 |
test(r==KErrNone);
|
sl@0
|
832 |
result=_L("2,1,0,5,4,3");
|
sl@0
|
833 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
834 |
delete dir;
|
sl@0
|
835 |
// Test DirLast - EDescending|EDirDescending
|
sl@0
|
836 |
sortOrder=ESortByName|EDirsLast|EDirDescending|EDescending;
|
sl@0
|
837 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
838 |
test(r==KErrNone);
|
sl@0
|
839 |
result=_L("5,4,3,2,1,0");
|
sl@0
|
840 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
841 |
delete dir;
|
sl@0
|
842 |
|
sl@0
|
843 |
// Test DirNoOrder - EDescending|EDirDescending
|
sl@0
|
844 |
sortOrder=ESortByName|EDescending|EDirDescending;
|
sl@0
|
845 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
846 |
test(r==KErrNone);
|
sl@0
|
847 |
result=_L("5,2,4,1,3,0");
|
sl@0
|
848 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
849 |
delete dir;
|
sl@0
|
850 |
// Test DirNoOrder - EDescending
|
sl@0
|
851 |
sortOrder=ESortByName|EDescending;
|
sl@0
|
852 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
853 |
test(r==KErrNone);
|
sl@0
|
854 |
result=_L("5,2,4,1,3,0");
|
sl@0
|
855 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
856 |
delete dir;
|
sl@0
|
857 |
// Test DirNoOrder - EAscending
|
sl@0
|
858 |
sortOrder=ESortByName;
|
sl@0
|
859 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir);
|
sl@0
|
860 |
test(r==KErrNone);
|
sl@0
|
861 |
result=_L("0,3,1,4,2,5");
|
sl@0
|
862 |
TestDirDescendingOrder(result,*dir);
|
sl@0
|
863 |
delete dir;
|
sl@0
|
864 |
}
|
sl@0
|
865 |
|
sl@0
|
866 |
//---------------------------------------------
|
sl@0
|
867 |
//! @SYMTestCaseID PBASE-T_GDIR-0815
|
sl@0
|
868 |
//! @SYMTestType UT
|
sl@0
|
869 |
//! @SYMREQ DEF122894
|
sl@0
|
870 |
//! @SYMTestCaseDesc This testcase tests the boundary condition of file name collation (8 characters).
|
sl@0
|
871 |
//! @SYMTestActions Creates file "xxxxxxxx2.dat" and "Xxxxxxxx1.dat" under same directory,
|
sl@0
|
872 |
//! retrieves dir list via GetDir(), sort list by name, check order of the file listed.
|
sl@0
|
873 |
//! @SYMTestExpectedResults File "Xxxxxxxx1.dat" should be listed before "xxxxxxxx2.dat".
|
sl@0
|
874 |
//! @SYMTestPriority High
|
sl@0
|
875 |
//! @SYMTestStatus Implemented
|
sl@0
|
876 |
//---------------------------------------------
|
sl@0
|
877 |
void TestDEF122894()
|
sl@0
|
878 |
{
|
sl@0
|
879 |
test.Next(_L("Test \"DEF122894: Defect in RFs GetDir() API\""));
|
sl@0
|
880 |
MakeFile(_L("\\F32-TST\\GDIR\\DEF122894\\xxxxxxxx2.dat"));
|
sl@0
|
881 |
MakeFile(_L("\\F32-TST\\GDIR\\DEF122894\\Xxxxxxxx1.dat"));
|
sl@0
|
882 |
CDir* dir;
|
sl@0
|
883 |
TInt r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\DEF122894\\"),KEntryAttMaskSupported,ESortByName|EAscending,dir);
|
sl@0
|
884 |
test(r==KErrNone);
|
sl@0
|
885 |
test(dir->Count() == 2);
|
sl@0
|
886 |
TEntry entry1, entry2;
|
sl@0
|
887 |
entry1 = (*dir)[0];
|
sl@0
|
888 |
entry2 = (*dir)[1];
|
sl@0
|
889 |
test(entry1.iName.Compare(_L("Xxxxxxxx1.dat")) == 0);
|
sl@0
|
890 |
test(entry2.iName.Compare(_L("xxxxxxxx2.dat")) == 0);
|
sl@0
|
891 |
delete dir;
|
sl@0
|
892 |
}
|
sl@0
|
893 |
|
sl@0
|
894 |
GLDEF_C void CallTestsL()
|
sl@0
|
895 |
//
|
sl@0
|
896 |
// Test directory handling.
|
sl@0
|
897 |
//
|
sl@0
|
898 |
{
|
sl@0
|
899 |
|
sl@0
|
900 |
CreateTestDirectory(_L("\\F32-TST\\GDIR\\"));
|
sl@0
|
901 |
if (gFirstRun)
|
sl@0
|
902 |
{
|
sl@0
|
903 |
gFirstRun=EFalse;
|
sl@0
|
904 |
testZDirectory();
|
sl@0
|
905 |
testZGetDirByUid();
|
sl@0
|
906 |
}
|
sl@0
|
907 |
|
sl@0
|
908 |
testSetup();
|
sl@0
|
909 |
testDir();
|
sl@0
|
910 |
testDisplayFiles();
|
sl@0
|
911 |
testGetDirByUid();
|
sl@0
|
912 |
testGetFilesExcept();
|
sl@0
|
913 |
testGetHidden();
|
sl@0
|
914 |
testDirDescending();
|
sl@0
|
915 |
TestDEF122894();
|
sl@0
|
916 |
DeleteTestDirectory();
|
sl@0
|
917 |
}
|
sl@0
|
918 |
|