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 |
// f32test\server\t_dirs.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <f32file.h>
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include "t_server.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "f32_test_utils.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
using namespace F32_Test_Utils;
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
RTest test(_L("T_DIRS"));
|
sl@0
|
28 |
|
sl@0
|
29 |
TTime gTimeNow;
|
sl@0
|
30 |
TBool gTestedZ = EFalse;
|
sl@0
|
31 |
TInt gDriveNum = -1;
|
sl@0
|
32 |
|
sl@0
|
33 |
static void Test1()
|
sl@0
|
34 |
//
|
sl@0
|
35 |
// Make a directory with lots of entries
|
sl@0
|
36 |
//
|
sl@0
|
37 |
{
|
sl@0
|
38 |
|
sl@0
|
39 |
RFile f;
|
sl@0
|
40 |
TInt maxEntry=56;
|
sl@0
|
41 |
test.Next(_L("Create a directory with 55 entries"));
|
sl@0
|
42 |
TFileName sessionPath;
|
sl@0
|
43 |
TInt r=TheFs.SessionPath(sessionPath);
|
sl@0
|
44 |
test(r==KErrNone);
|
sl@0
|
45 |
r=TheFs.MkDir(_L("\\F32-TST\\"));
|
sl@0
|
46 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
47 |
r=TheFs.MkDir(_L("\\F32-TST\\TDIRS\\"));
|
sl@0
|
48 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
49 |
|
sl@0
|
50 |
for (TInt i=0;i<maxEntry;i++)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
TFileName baseName=_L("\\F32-TST\\TDIRS\\FILE");
|
sl@0
|
53 |
baseName.AppendNum(i);
|
sl@0
|
54 |
r=f.Replace(TheFs,baseName,EFileRead);
|
sl@0
|
55 |
test(r==KErrNone);
|
sl@0
|
56 |
r=f.Write(_L8("Hello World"));
|
sl@0
|
57 |
test(r==KErrNone);
|
sl@0
|
58 |
f.Close();
|
sl@0
|
59 |
}
|
sl@0
|
60 |
test.Next(_L("Test all entries have been created successfully."));
|
sl@0
|
61 |
for (TInt j=0;j<=maxEntry;j++)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
TFileName baseName=_L("\\F32-TST\\TDIRS\\FILE");
|
sl@0
|
64 |
baseName.AppendNum(j);
|
sl@0
|
65 |
TInt r=f.Open(TheFs,baseName,EFileRead);
|
sl@0
|
66 |
if (r!=KErrNone)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
test(r==KErrNotFound && j==maxEntry);
|
sl@0
|
69 |
return;
|
sl@0
|
70 |
}
|
sl@0
|
71 |
TBuf8<16> data;
|
sl@0
|
72 |
r=f.Read(data);
|
sl@0
|
73 |
test(r==KErrNone);
|
sl@0
|
74 |
test(data==_L8("Hello World"));
|
sl@0
|
75 |
f.Close();
|
sl@0
|
76 |
}
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
static void Test2()
|
sl@0
|
80 |
//
|
sl@0
|
81 |
// List all directory entries
|
sl@0
|
82 |
//
|
sl@0
|
83 |
{
|
sl@0
|
84 |
|
sl@0
|
85 |
test.Printf(_L("List all entries in directory %S\n"),&gSessionPath);
|
sl@0
|
86 |
RDir d;
|
sl@0
|
87 |
|
sl@0
|
88 |
TInt r=d.Open(TheFs,gSessionPath,KEntryAttMaskSupported);
|
sl@0
|
89 |
if (r==KErrNone)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
TEntry e;
|
sl@0
|
92 |
while ((r=d.Read(e))==KErrNone)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
if (e.IsDir())
|
sl@0
|
95 |
test.Printf(_L("%- 20S <DIR>\n"),&e.iName);
|
sl@0
|
96 |
else
|
sl@0
|
97 |
test.Printf(_L("%- 20S %+ 8d\n"),&e.iName,e.iSize);
|
sl@0
|
98 |
}
|
sl@0
|
99 |
d.Close();
|
sl@0
|
100 |
if (r!=KErrEof)
|
sl@0
|
101 |
test.Printf(_L("Error %d\n"),r);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
else
|
sl@0
|
104 |
test.Printf(_L("Error %d\n"),r);
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
static void TestZ()
|
sl@0
|
108 |
//
|
sl@0
|
109 |
// Check you cannot open a directory on a file
|
sl@0
|
110 |
//
|
sl@0
|
111 |
{
|
sl@0
|
112 |
|
sl@0
|
113 |
test.Next(_L("Open files and directories on Z:"));
|
sl@0
|
114 |
TEntry entry;
|
sl@0
|
115 |
RDir d;
|
sl@0
|
116 |
|
sl@0
|
117 |
TInt r=d.Open(TheFs,PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("\\Sys\\Bin\\ESHELL.EXE\\*"):_L("\\System\\Bin\\ESHELL.EXE\\*"),KEntryAttMaskSupported);
|
sl@0
|
118 |
test(r==KErrPathNotFound);
|
sl@0
|
119 |
|
sl@0
|
120 |
r=d.Open(TheFs,PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("\\Sys\\Bin\\ESHELL.EXE"):_L("\\System\\Bin\\ESHELL.EXE"),KEntryAttMaskSupported);
|
sl@0
|
121 |
test(r==KErrNone);
|
sl@0
|
122 |
|
sl@0
|
123 |
r=d.Read(entry);
|
sl@0
|
124 |
if (r==KErrEof)
|
sl@0
|
125 |
{
|
sl@0
|
126 |
test.Printf(_L("Error: EShell.EXE not found\n"));
|
sl@0
|
127 |
//test.Getch();
|
sl@0
|
128 |
}
|
sl@0
|
129 |
else
|
sl@0
|
130 |
{
|
sl@0
|
131 |
test(r==KErrNone);
|
sl@0
|
132 |
test(entry.iName.FindF(_L("ESHELL.EXE"))>=0);
|
sl@0
|
133 |
r=d.Read(entry);
|
sl@0
|
134 |
test(r==KErrEof);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
d.Close();
|
sl@0
|
137 |
|
sl@0
|
138 |
r=d.Open(TheFs,_L("\\*.XQP"),KEntryAttMaskSupported);
|
sl@0
|
139 |
test(r==KErrNone);
|
sl@0
|
140 |
r=d.Read(entry);
|
sl@0
|
141 |
test(r==KErrEof);
|
sl@0
|
142 |
d.Close();
|
sl@0
|
143 |
|
sl@0
|
144 |
r=d.Open(TheFs,PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("\\Sys\\Bin\\"):_L("\\System\\Bin\\"),KEntryAttMaskSupported);
|
sl@0
|
145 |
test(r==KErrNone);
|
sl@0
|
146 |
r=d.Read(entry);
|
sl@0
|
147 |
|
sl@0
|
148 |
if (r==KErrEof)
|
sl@0
|
149 |
{
|
sl@0
|
150 |
test.Printf(_L("No files found\n"));
|
sl@0
|
151 |
d.Close();
|
sl@0
|
152 |
}
|
sl@0
|
153 |
else
|
sl@0
|
154 |
{
|
sl@0
|
155 |
test(r==KErrNone);
|
sl@0
|
156 |
test.Printf(_L("First Entry = %S\n"),&entry.iName);
|
sl@0
|
157 |
r=d.Read(entry);
|
sl@0
|
158 |
test(r==KErrNone);
|
sl@0
|
159 |
test.Printf(_L("Second Entry = %S\n"),&entry.iName);
|
sl@0
|
160 |
d.Close();
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
r=d.Open(TheFs,_L("\\*"),KEntryAttMaskSupported);
|
sl@0
|
164 |
test(r==KErrNone);
|
sl@0
|
165 |
d.Close();
|
sl@0
|
166 |
r=d.Open(TheFs,PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("\\Sys\\Bin\\*"):_L("\\System\\Bin\\*"),KEntryAttMaskSupported);
|
sl@0
|
167 |
test(r==KErrNone);
|
sl@0
|
168 |
d.Close();
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
static void Test3()
|
sl@0
|
172 |
//
|
sl@0
|
173 |
// Check you cannot open a directory on a file
|
sl@0
|
174 |
//
|
sl@0
|
175 |
{
|
sl@0
|
176 |
|
sl@0
|
177 |
test.Next(_L("Open files and directories"));
|
sl@0
|
178 |
TEntry entry;
|
sl@0
|
179 |
RFile f;
|
sl@0
|
180 |
TInt r=f.Replace(TheFs,_L("\\F32-TST\\TDIRS\\TESTFILEORISITA.DIR"),EFileWrite);
|
sl@0
|
181 |
test(r==KErrNone);
|
sl@0
|
182 |
r=f.Write(_L8("TESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATA"));
|
sl@0
|
183 |
test(r==KErrNone);
|
sl@0
|
184 |
r=TheFs.Delete(_L("\\F32-TST\\TDIRS\\TESTFILEORISITA.DIR"));
|
sl@0
|
185 |
test(r==KErrInUse);
|
sl@0
|
186 |
f.Close();
|
sl@0
|
187 |
RDir d;
|
sl@0
|
188 |
r=d.Open(TheFs,_L("\\F32-TST\\TDIRS\\TESTFILEORISITA.DIR\\*"),KEntryAttMaskSupported);
|
sl@0
|
189 |
test(r==KErrPathNotFound);
|
sl@0
|
190 |
r=d.Open(TheFs,_L("\\F32-TST\\TDIRS\\*.XQP"),KEntryAttMaskSupported);
|
sl@0
|
191 |
test(r==KErrNone);
|
sl@0
|
192 |
r=d.Read(entry);
|
sl@0
|
193 |
test(r==KErrEof);
|
sl@0
|
194 |
d.Close();
|
sl@0
|
195 |
r=d.Open(TheFs,_L("\\F32-TST\\TDIRS\\TESTFILEORISITA.DIR"),KEntryAttMaskSupported);
|
sl@0
|
196 |
test(r==KErrNone);
|
sl@0
|
197 |
r=d.Read(entry);
|
sl@0
|
198 |
test(r==KErrNone);
|
sl@0
|
199 |
test(entry.iName.FindF(_L("TESTFILEORISITA.DIR"))>=0);
|
sl@0
|
200 |
r=d.Read(entry);
|
sl@0
|
201 |
test(r==KErrEof);
|
sl@0
|
202 |
d.Close();
|
sl@0
|
203 |
r=d.Open(TheFs,_L("\\"),KEntryAttMaskSupported);
|
sl@0
|
204 |
test(r==KErrNone);
|
sl@0
|
205 |
d.Close();
|
sl@0
|
206 |
r=d.Open(TheFs,_L("\\F32-TST\\"),KEntryAttMaskSupported);
|
sl@0
|
207 |
test(r==KErrNone);
|
sl@0
|
208 |
d.Close();
|
sl@0
|
209 |
r=d.Open(TheFs,_L("\\*"),KEntryAttMaskSupported);
|
sl@0
|
210 |
test(r==KErrNone);
|
sl@0
|
211 |
d.Close();
|
sl@0
|
212 |
r=d.Open(TheFs,_L("\\F32-TST\\*"),KEntryAttMaskSupported);
|
sl@0
|
213 |
test(r==KErrNone);
|
sl@0
|
214 |
d.Close();
|
sl@0
|
215 |
|
sl@0
|
216 |
// create a small file on the root
|
sl@0
|
217 |
test(f.Replace(TheFs, _L("\\TEST.FILE"), EFileWrite) == KErrNone);
|
sl@0
|
218 |
test(f.Write(_L8("1234567890987654321234567890")) == KErrNone);
|
sl@0
|
219 |
f.Close();
|
sl@0
|
220 |
// try some directory operations on the file
|
sl@0
|
221 |
test(TheFs.RmDir(_L("\\TEST.FILE\\")) == KErrPathNotFound);
|
sl@0
|
222 |
test(TheFs.RmDir(_L("\\TEST.FILE\\ZZZ\\")) == KErrPathNotFound);
|
sl@0
|
223 |
test(TheFs.MkDir(_L("\\TEST.FILE\\ZZZ\\")) == KErrPathNotFound);
|
sl@0
|
224 |
// cleanup
|
sl@0
|
225 |
TheFs.Delete(_L("\\TEST.FILE"));
|
sl@0
|
226 |
|
sl@0
|
227 |
|
sl@0
|
228 |
r=TheFs.MkDir(_L("\\F32-TST\\EMPTY\\"));
|
sl@0
|
229 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
230 |
r=d.Open(TheFs,_L("\\F32-TST\\EMPTY\\*"),KEntryAttMaskSupported);
|
sl@0
|
231 |
test(r==KErrNone);
|
sl@0
|
232 |
// r=TheFs.RmDir(_L("\\F32-TST\\EMPTY\\"));
|
sl@0
|
233 |
r=d.Read(entry);
|
sl@0
|
234 |
test(r==KErrEof);
|
sl@0
|
235 |
// r=TheFs.RmDir(_L("\\F32-TST\\EMPTY\\"));
|
sl@0
|
236 |
// test(r==KErrInUse);
|
sl@0
|
237 |
r=d.Read(entry);
|
sl@0
|
238 |
r=d.Read(entry);
|
sl@0
|
239 |
r=d.Read(entry);
|
sl@0
|
240 |
d.Close();
|
sl@0
|
241 |
r=TheFs.RmDir(_L("\\F32-TST\\EMPTY\\"));
|
sl@0
|
242 |
test(r==KErrNone);
|
sl@0
|
243 |
}
|
sl@0
|
244 |
|
sl@0
|
245 |
|
sl@0
|
246 |
static void CreateSortNoneTestDirectoryStructure()
|
sl@0
|
247 |
//
|
sl@0
|
248 |
// Create files
|
sl@0
|
249 |
//
|
sl@0
|
250 |
{
|
sl@0
|
251 |
// Delete the directory to be tested if it already exists as a result of this
|
sl@0
|
252 |
// test being run previously. It's necessary remove it and then recreate it
|
sl@0
|
253 |
// because a later test relies on the time of file/directory creation to be
|
sl@0
|
254 |
// the time this function was run...
|
sl@0
|
255 |
|
sl@0
|
256 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
257 |
test(fMan!=NULL);
|
sl@0
|
258 |
TInt r=fMan->RmDir(_L("\\F32-TST\\TDIRS\\SORT_NONE\\"));
|
sl@0
|
259 |
test((r==KErrNone)||(r==KErrPathNotFound));
|
sl@0
|
260 |
delete fMan;
|
sl@0
|
261 |
|
sl@0
|
262 |
gTimeNow.HomeTime(); // Set global TTime gTimeNow to time now - for later tests
|
sl@0
|
263 |
r=TheFs.MkDirAll(_L("\\F32-TST\\TDIRS\\SORT_NONE\\"));
|
sl@0
|
264 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
265 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file1.txt"));
|
sl@0
|
266 |
r=TheFs.MkDir(_L("\\F32-TST\\TDIRS\\SORT_NONE\\FILE_DIR1.APP\\"));
|
sl@0
|
267 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
268 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file1.app"));
|
sl@0
|
269 |
r=TheFs.MkDir(_L("\\F32-TST\\TDIRS\\SORT_NONE\\FILE_DIR2.TXT\\"));
|
sl@0
|
270 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
271 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file2.txt"));
|
sl@0
|
272 |
r=TheFs.MkDir(_L("\\F32-TST\\TDIRS\\SORT_NONE\\FILE_DIR3.APP\\"));
|
sl@0
|
273 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
274 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\ZZZZ"));
|
sl@0
|
275 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\AAAA"));
|
sl@0
|
276 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\WWWW"));
|
sl@0
|
277 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file2.app"));
|
sl@0
|
278 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file3.txt"));
|
sl@0
|
279 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file3.app"));
|
sl@0
|
280 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\NOEXT1"));
|
sl@0
|
281 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\NOEXT2"));
|
sl@0
|
282 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\EXTMISSING"));
|
sl@0
|
283 |
}
|
sl@0
|
284 |
|
sl@0
|
285 |
static void Test4()
|
sl@0
|
286 |
//
|
sl@0
|
287 |
// Test ESortNone
|
sl@0
|
288 |
//
|
sl@0
|
289 |
{
|
sl@0
|
290 |
|
sl@0
|
291 |
test.Next(_L("Test ESortNone"));
|
sl@0
|
292 |
CreateSortNoneTestDirectoryStructure();
|
sl@0
|
293 |
CDir* dir;
|
sl@0
|
294 |
CDir* dirSorted;
|
sl@0
|
295 |
|
sl@0
|
296 |
//
|
sl@0
|
297 |
// GetDir OOM failure passes 'callback' test from client side but not server side
|
sl@0
|
298 |
//
|
sl@0
|
299 |
TheFs.SetAllocFailure(gAllocFailOff);
|
sl@0
|
300 |
|
sl@0
|
301 |
TInt r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*"),KEntryAttMaskSupported,ESortNone,dir);
|
sl@0
|
302 |
test(r==KErrNone);
|
sl@0
|
303 |
TInt count=dir->Count();
|
sl@0
|
304 |
test(count==15);
|
sl@0
|
305 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*"),KEntryAttMaskSupported,ESortByName,dirSorted);
|
sl@0
|
306 |
test(r==KErrNone);
|
sl@0
|
307 |
test(dirSorted->Count()==15);
|
sl@0
|
308 |
delete dirSorted;
|
sl@0
|
309 |
delete dir;
|
sl@0
|
310 |
|
sl@0
|
311 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.txt"),KEntryAttNormal,ESortNone,dir);
|
sl@0
|
312 |
test(r==KErrNone);
|
sl@0
|
313 |
test(dir->Count()==3);
|
sl@0
|
314 |
delete dir;
|
sl@0
|
315 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.app"),KEntryAttNormal,ESortNone,dir);
|
sl@0
|
316 |
test(r==KErrNone);
|
sl@0
|
317 |
test(dir->Count()==3);
|
sl@0
|
318 |
delete dir;
|
sl@0
|
319 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.app"),KEntryAttNormal|KEntryAttDir,ESortNone,dir);
|
sl@0
|
320 |
test(r==KErrNone);
|
sl@0
|
321 |
test(dir->Count()==5);
|
sl@0
|
322 |
delete dir;
|
sl@0
|
323 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.app"),KEntryAttNormal|KEntryAttDir,ESortNone|EDirsFirst,dir);
|
sl@0
|
324 |
test(r==KErrNone);
|
sl@0
|
325 |
test(dir->Count()==5);
|
sl@0
|
326 |
delete dir;
|
sl@0
|
327 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.app"),KEntryAttNormal|KEntryAttDir,ESortNone|EDirsLast,dir);
|
sl@0
|
328 |
test(r==KErrNone);
|
sl@0
|
329 |
test(dir->Count()==5);
|
sl@0
|
330 |
delete dir;
|
sl@0
|
331 |
|
sl@0
|
332 |
TheFs.SetAllocFailure(gAllocFailOn);
|
sl@0
|
333 |
}
|
sl@0
|
334 |
|
sl@0
|
335 |
static void Test5()
|
sl@0
|
336 |
//
|
sl@0
|
337 |
// Test return values
|
sl@0
|
338 |
//
|
sl@0
|
339 |
{
|
sl@0
|
340 |
|
sl@0
|
341 |
test.Next(_L("Test return values"));
|
sl@0
|
342 |
RDir dir;
|
sl@0
|
343 |
TInt r=dir.Open(TheFs,_L("\\DoesNotExist\\*"),KEntryAttMaskSupported);
|
sl@0
|
344 |
test(r==KErrPathNotFound);
|
sl@0
|
345 |
r=dir.Open(TheFs,_L("\\"),KEntryAttMaskSupported);
|
sl@0
|
346 |
test(r==KErrNone);
|
sl@0
|
347 |
dir.Close();
|
sl@0
|
348 |
}
|
sl@0
|
349 |
|
sl@0
|
350 |
|
sl@0
|
351 |
static void Test6()
|
sl@0
|
352 |
//
|
sl@0
|
353 |
// Test that "*.*" matches all files/directories
|
sl@0
|
354 |
//
|
sl@0
|
355 |
{
|
sl@0
|
356 |
|
sl@0
|
357 |
test.Next(_L("Test *.* matches all files"));
|
sl@0
|
358 |
CDir* dirList;
|
sl@0
|
359 |
TInt r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.*"),KEntryAttNormal|KEntryAttDir,ESortByName|EDirsLast,dirList);
|
sl@0
|
360 |
test(r==KErrNone);
|
sl@0
|
361 |
TInt count=dirList->Count();
|
sl@0
|
362 |
test(count==15);
|
sl@0
|
363 |
TEntry entry=(*dirList)[0];
|
sl@0
|
364 |
test(entry.iName.FindF(_L("AAAA"))>=0);
|
sl@0
|
365 |
entry=(*dirList)[1];
|
sl@0
|
366 |
test(entry.iName.FindF(_L("EXTMISSING"))>=0);
|
sl@0
|
367 |
entry=(*dirList)[2];
|
sl@0
|
368 |
test(entry.iName.FindF(_L("FILE1.APP"))>=0);
|
sl@0
|
369 |
entry=(*dirList)[3];
|
sl@0
|
370 |
test(entry.iName.FindF(_L("FILE1.TXT"))>=0);
|
sl@0
|
371 |
entry=(*dirList)[4];
|
sl@0
|
372 |
test(entry.iName.FindF(_L("FILE2.APP"))>=0);
|
sl@0
|
373 |
entry=(*dirList)[5];
|
sl@0
|
374 |
test(entry.iName.FindF(_L("FILE2.TXT"))>=0);
|
sl@0
|
375 |
entry=(*dirList)[6];
|
sl@0
|
376 |
test(entry.iName.FindF(_L("FILE3.APP"))>=0);
|
sl@0
|
377 |
entry=(*dirList)[7];
|
sl@0
|
378 |
test(entry.iName.FindF(_L("FILE3.TXT"))>=0);
|
sl@0
|
379 |
entry=(*dirList)[8];
|
sl@0
|
380 |
test(entry.iName.FindF(_L("NOEXT1"))>=0);
|
sl@0
|
381 |
entry=(*dirList)[9];
|
sl@0
|
382 |
test(entry.iName.FindF(_L("NOEXT2"))>=0);
|
sl@0
|
383 |
entry=(*dirList)[10];
|
sl@0
|
384 |
test(entry.iName.FindF(_L("WWWW"))>=0);
|
sl@0
|
385 |
entry=(*dirList)[11];
|
sl@0
|
386 |
test(entry.iName.FindF(_L("ZZZZ"))>=0);
|
sl@0
|
387 |
entry=(*dirList)[12];
|
sl@0
|
388 |
test(entry.iName.FindF(_L("FILE_DIR1.APP"))>=0);
|
sl@0
|
389 |
entry=(*dirList)[13];
|
sl@0
|
390 |
test(entry.iName.FindF(_L("FILE_DIR2.TXT"))>=0);
|
sl@0
|
391 |
entry=(*dirList)[14];
|
sl@0
|
392 |
test(entry.iName.FindF(_L("FILE_DIR3.APP"))>=0);
|
sl@0
|
393 |
delete dirList;
|
sl@0
|
394 |
|
sl@0
|
395 |
RDir dir;
|
sl@0
|
396 |
r=dir.Open(TheFs,_L("\\f32-tst\\tdirs\\sort_none\\*.*"),KEntryAttNormal|KEntryAttDir);
|
sl@0
|
397 |
test(r==KErrNone);
|
sl@0
|
398 |
|
sl@0
|
399 |
TTime time;
|
sl@0
|
400 |
TInt64 difference;
|
sl@0
|
401 |
TInt64 maxOK=1000000;
|
sl@0
|
402 |
maxOK*=60;
|
sl@0
|
403 |
maxOK*=3;
|
sl@0
|
404 |
|
sl@0
|
405 |
for (TInt i=0; i<15; i++)
|
sl@0
|
406 |
{
|
sl@0
|
407 |
r=dir.Read(entry);
|
sl@0
|
408 |
test(r==KErrNone);
|
sl@0
|
409 |
time=entry.iModified;
|
sl@0
|
410 |
difference=time.Int64()-gTimeNow.Int64();
|
sl@0
|
411 |
test(difference<maxOK);
|
sl@0
|
412 |
}
|
sl@0
|
413 |
|
sl@0
|
414 |
r=dir.Read(entry);
|
sl@0
|
415 |
test(r==KErrEof);
|
sl@0
|
416 |
dir.Close();
|
sl@0
|
417 |
|
sl@0
|
418 |
TheFs.SetAllocFailure(gAllocFailOn);
|
sl@0
|
419 |
}
|
sl@0
|
420 |
|
sl@0
|
421 |
|
sl@0
|
422 |
static void Test7()
|
sl@0
|
423 |
//
|
sl@0
|
424 |
// Fill up the root directory
|
sl@0
|
425 |
//
|
sl@0
|
426 |
{
|
sl@0
|
427 |
test.Next(_L("Fill up the root directory"));
|
sl@0
|
428 |
|
sl@0
|
429 |
if(!Is_Fat12(TheFs, gDriveNum) && !Is_Fat16(TheFs, gDriveNum))
|
sl@0
|
430 |
{
|
sl@0
|
431 |
test.Printf(_L("Skipping. Applicable for FAT12/16 only!\n"));
|
sl@0
|
432 |
return;
|
sl@0
|
433 |
}
|
sl@0
|
434 |
|
sl@0
|
435 |
TInt r = FormatDrive(TheFs, gDriveNum, ETrue);
|
sl@0
|
436 |
test(r==KErrNone);
|
sl@0
|
437 |
|
sl@0
|
438 |
TBuf<32> baseName=_L("\\RD");
|
sl@0
|
439 |
TBuf<32> id;
|
sl@0
|
440 |
TBuf<32> fileName;
|
sl@0
|
441 |
TInt count=0;
|
sl@0
|
442 |
|
sl@0
|
443 |
RFile f;
|
sl@0
|
444 |
TParsePtrC parser(gSessionPath);
|
sl@0
|
445 |
FOREVER
|
sl@0
|
446 |
{
|
sl@0
|
447 |
id.Num(count+1);
|
sl@0
|
448 |
fileName=parser.Drive();
|
sl@0
|
449 |
fileName+=baseName;
|
sl@0
|
450 |
fileName+=id;
|
sl@0
|
451 |
TInt r=f.Replace(TheFs,fileName,EFileWrite);
|
sl@0
|
452 |
if(r==KErrDirFull)
|
sl@0
|
453 |
{
|
sl@0
|
454 |
break;
|
sl@0
|
455 |
}
|
sl@0
|
456 |
test(r==KErrNone);
|
sl@0
|
457 |
f.Close();
|
sl@0
|
458 |
count++;
|
sl@0
|
459 |
if(count >= 1000)
|
sl@0
|
460 |
{
|
sl@0
|
461 |
break;
|
sl@0
|
462 |
}
|
sl@0
|
463 |
test.Printf(_L("CreateFile : %d : %S\r"),count,&fileName);
|
sl@0
|
464 |
}
|
sl@0
|
465 |
test.Printf(_L("\n"));
|
sl@0
|
466 |
|
sl@0
|
467 |
while (count)
|
sl@0
|
468 |
{
|
sl@0
|
469 |
id.Num(count);
|
sl@0
|
470 |
fileName=parser.Drive();
|
sl@0
|
471 |
fileName+=baseName;
|
sl@0
|
472 |
fileName+=id;
|
sl@0
|
473 |
TInt r=TheFs.Delete(fileName);
|
sl@0
|
474 |
test(r==KErrNone);
|
sl@0
|
475 |
test.Printf(_L("DeleteFile : %d : %S\r"),count,&fileName);
|
sl@0
|
476 |
--count;
|
sl@0
|
477 |
}
|
sl@0
|
478 |
test.Printf(_L("\n"));
|
sl@0
|
479 |
|
sl@0
|
480 |
test.Next(_L("Long filenames in root"));
|
sl@0
|
481 |
TFileName longFileName;
|
sl@0
|
482 |
longFileName.SetLength(254);
|
sl@0
|
483 |
// Mem::Fill((TUint8*)longFileName.Ptr(),254,'A');
|
sl@0
|
484 |
Mem::Fill((TUint8*)longFileName.Ptr(),254*sizeof(TText),'A');
|
sl@0
|
485 |
longFileName[0]='\\';
|
sl@0
|
486 |
longFileName[253]='\\';
|
sl@0
|
487 |
r=TheFs.MkDir(longFileName);
|
sl@0
|
488 |
test(r==KErrNone);
|
sl@0
|
489 |
CDir* dirList=NULL;
|
sl@0
|
490 |
r=TheFs.GetDir(longFileName,KEntryAttMaskSupported,ESortByName,dirList);
|
sl@0
|
491 |
test(r==KErrNone);
|
sl@0
|
492 |
count=dirList->Count();
|
sl@0
|
493 |
test(count==0);
|
sl@0
|
494 |
delete dirList;
|
sl@0
|
495 |
TParse parse;
|
sl@0
|
496 |
r=TheFs.Parse(longFileName,parse);
|
sl@0
|
497 |
test(r==KErrNone);
|
sl@0
|
498 |
TEntry entry;
|
sl@0
|
499 |
r=TheFs.Entry(longFileName,entry);
|
sl@0
|
500 |
test(r==KErrNone);
|
sl@0
|
501 |
r=TheFs.SetSessionPath(longFileName);
|
sl@0
|
502 |
test(r==KErrNone);
|
sl@0
|
503 |
r=TheFs.GetDir(longFileName,KEntryAttMaskSupported,ESortByName,dirList);
|
sl@0
|
504 |
test(r==KErrNone);
|
sl@0
|
505 |
count=dirList->Count();
|
sl@0
|
506 |
test(count==0);
|
sl@0
|
507 |
delete dirList;
|
sl@0
|
508 |
r=TheFs.Parse(longFileName,_L("*"),parse);
|
sl@0
|
509 |
test(r==KErrBadName);
|
sl@0
|
510 |
r=f.Open(TheFs,_L("asdf.asdf"),0);
|
sl@0
|
511 |
test(r==KErrBadName);
|
sl@0
|
512 |
r=TheFs.Entry(longFileName,entry);
|
sl@0
|
513 |
test(r==KErrNone);
|
sl@0
|
514 |
r=TheFs.RmDir(longFileName);
|
sl@0
|
515 |
test(r==KErrNone);
|
sl@0
|
516 |
}
|
sl@0
|
517 |
|
sl@0
|
518 |
static void Test8()
|
sl@0
|
519 |
//
|
sl@0
|
520 |
// Regression tests
|
sl@0
|
521 |
//
|
sl@0
|
522 |
{
|
sl@0
|
523 |
|
sl@0
|
524 |
test.Next(_L("Open dir and change drives"));
|
sl@0
|
525 |
MakeDir(_L("C:\\MOON\\"));
|
sl@0
|
526 |
RDir dir;
|
sl@0
|
527 |
TInt r=dir.Open(TheFs,_L("C:\\MOON\\"),0);
|
sl@0
|
528 |
test(r==KErrNone);
|
sl@0
|
529 |
TFileName driveName;
|
sl@0
|
530 |
r=TheFs.GetDriveName(11,driveName);
|
sl@0
|
531 |
test(r==KErrNone);
|
sl@0
|
532 |
TEntryArray entryArray;
|
sl@0
|
533 |
r=dir.Read(entryArray);
|
sl@0
|
534 |
test(r==KErrEof);
|
sl@0
|
535 |
test(entryArray.Count()==0);
|
sl@0
|
536 |
dir.Close();
|
sl@0
|
537 |
r=TheFs.RmDir(_L("C:\\MOON\\"));
|
sl@0
|
538 |
test(r==KErrNone);
|
sl@0
|
539 |
|
sl@0
|
540 |
test.Next(_L("MkDir all on nonexistent drive"));
|
sl@0
|
541 |
r=TheFs.MkDirAll(_L("L:\\MOON"));
|
sl@0
|
542 |
test((r==KErrNotReady)||(r==KErrPathNotFound));
|
sl@0
|
543 |
}
|
sl@0
|
544 |
|
sl@0
|
545 |
static void CleanupL()
|
sl@0
|
546 |
//
|
sl@0
|
547 |
// Clean up tests
|
sl@0
|
548 |
//
|
sl@0
|
549 |
{
|
sl@0
|
550 |
|
sl@0
|
551 |
test.Next(_L("Delete test directory"));
|
sl@0
|
552 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
553 |
TInt r=fMan->RmDir(gSessionPath);
|
sl@0
|
554 |
test(r==KErrNone);
|
sl@0
|
555 |
r=fMan->Delete(_L("\\Filluptherootdir*"));
|
sl@0
|
556 |
test(r==KErrNone || r==KErrNotFound);
|
sl@0
|
557 |
delete fMan;
|
sl@0
|
558 |
}
|
sl@0
|
559 |
|
sl@0
|
560 |
static void Test9()
|
sl@0
|
561 |
//
|
sl@0
|
562 |
// Test directories with trailing dots (ref. DEF047684)
|
sl@0
|
563 |
//
|
sl@0
|
564 |
{
|
sl@0
|
565 |
|
sl@0
|
566 |
test.Next(_L("Testing directory names with trailing dots"));
|
sl@0
|
567 |
TInt r;
|
sl@0
|
568 |
r=TheFs.MkDir(_L("\\test9..\\"));
|
sl@0
|
569 |
test(r==KErrBadName);
|
sl@0
|
570 |
r=TheFs.MkDir(_L("\\test9\\"));
|
sl@0
|
571 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
572 |
r=TheFs.Rename(_L("\\test9\\"),_L("\\test9..\\"));
|
sl@0
|
573 |
test(r==KErrBadName);
|
sl@0
|
574 |
r= TheFs.RmDir(_L("\\test9\\"));
|
sl@0
|
575 |
test((r==KErrNone));
|
sl@0
|
576 |
r=TheFs.MkDir(_L("\\t.\\"));
|
sl@0
|
577 |
test(r==KErrBadName);
|
sl@0
|
578 |
}
|
sl@0
|
579 |
|
sl@0
|
580 |
|
sl@0
|
581 |
//
|
sl@0
|
582 |
// Path and File names for sorting by name
|
sl@0
|
583 |
//
|
sl@0
|
584 |
// The correctly sorted directory listing should be:
|
sl@0
|
585 |
//
|
sl@0
|
586 |
// b.doc
|
sl@0
|
587 |
// bb.doc
|
sl@0
|
588 |
// bs.doc
|
sl@0
|
589 |
//
|
sl@0
|
590 |
_LIT(KSortByNamePath, "\\F32-TST\\TDIRS\\SORT_NAME\\");
|
sl@0
|
591 |
_LIT(KFileBS, "bs.doc");
|
sl@0
|
592 |
_LIT(KFileBB, "bb.doc");
|
sl@0
|
593 |
_LIT(KFileB, "b.doc");
|
sl@0
|
594 |
_LIT(KSortAll, "*.*");
|
sl@0
|
595 |
_LIT(KPrintFileName, "%S\n");
|
sl@0
|
596 |
|
sl@0
|
597 |
|
sl@0
|
598 |
static void DeleteTestDirectoryStructure(const TDesC& aPath)
|
sl@0
|
599 |
//
|
sl@0
|
600 |
// Delete the directory to be tested if it already exists as a result of this
|
sl@0
|
601 |
// test being run previously.
|
sl@0
|
602 |
//
|
sl@0
|
603 |
{
|
sl@0
|
604 |
|
sl@0
|
605 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
606 |
test(fMan!=NULL);
|
sl@0
|
607 |
TInt r=fMan->RmDir(aPath);
|
sl@0
|
608 |
test((r==KErrNone)||(r==KErrPathNotFound));
|
sl@0
|
609 |
delete fMan;
|
sl@0
|
610 |
}
|
sl@0
|
611 |
|
sl@0
|
612 |
|
sl@0
|
613 |
static void CreateTestDirectoryStructure(const TDesC& aPath, const TDesC** aFileArray, TInt aNumFiles)
|
sl@0
|
614 |
//
|
sl@0
|
615 |
// Create files
|
sl@0
|
616 |
//
|
sl@0
|
617 |
{
|
sl@0
|
618 |
DeleteTestDirectoryStructure(aPath);
|
sl@0
|
619 |
|
sl@0
|
620 |
gTimeNow.HomeTime(); // Set global TTime gTimeNow to time now - for later tests
|
sl@0
|
621 |
TInt r=TheFs.MkDirAll(aPath);
|
sl@0
|
622 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
623 |
|
sl@0
|
624 |
TBuf<128> fileName;
|
sl@0
|
625 |
for (TInt i = 0; i < aNumFiles; i++)
|
sl@0
|
626 |
{
|
sl@0
|
627 |
fileName = aPath;
|
sl@0
|
628 |
fileName.Append(*aFileArray[i]);
|
sl@0
|
629 |
MakeFile(fileName);
|
sl@0
|
630 |
}
|
sl@0
|
631 |
}
|
sl@0
|
632 |
|
sl@0
|
633 |
|
sl@0
|
634 |
static void TestSortByName()
|
sl@0
|
635 |
//
|
sl@0
|
636 |
// Test that sorting by name works for different length filenames.
|
sl@0
|
637 |
//
|
sl@0
|
638 |
{
|
sl@0
|
639 |
const TDesC* theFiles[] = {&KFileBS, &KFileBB, &KFileB};
|
sl@0
|
640 |
TInt numFiles = sizeof(theFiles)/sizeof(theFiles[0]);
|
sl@0
|
641 |
CreateTestDirectoryStructure(KSortByNamePath, theFiles, numFiles);
|
sl@0
|
642 |
|
sl@0
|
643 |
test.Next(_L("Test ESortByName"));
|
sl@0
|
644 |
CDir* dirList;
|
sl@0
|
645 |
TBuf<128> sortSpec(KSortByNamePath);
|
sl@0
|
646 |
sortSpec.Append(KSortAll);
|
sl@0
|
647 |
TInt r=TheFs.GetDir(sortSpec, KEntryAttNormal | KEntryAttDir, ESortByName | EDirsLast, dirList);
|
sl@0
|
648 |
test(r==KErrNone);
|
sl@0
|
649 |
TInt count=dirList->Count();
|
sl@0
|
650 |
test(count==numFiles);
|
sl@0
|
651 |
|
sl@0
|
652 |
|
sl@0
|
653 |
TInt i;
|
sl@0
|
654 |
for (i = 0; i < count; i++)
|
sl@0
|
655 |
{
|
sl@0
|
656 |
test.Printf(KPrintFileName, &(*dirList)[i].iName);
|
sl@0
|
657 |
}
|
sl@0
|
658 |
|
sl@0
|
659 |
TEntry entry=(*dirList)[0];
|
sl@0
|
660 |
test(entry.iName.FindF(KFileB)>=0);
|
sl@0
|
661 |
entry=(*dirList)[1];
|
sl@0
|
662 |
test(entry.iName.FindF(KFileBB)>=0);
|
sl@0
|
663 |
entry=(*dirList)[2];
|
sl@0
|
664 |
test(entry.iName.FindF(KFileBS)>=0);
|
sl@0
|
665 |
delete dirList;
|
sl@0
|
666 |
dirList = 0;
|
sl@0
|
667 |
|
sl@0
|
668 |
|
sl@0
|
669 |
test.Next(_L("Test ESortByName (descending)"));
|
sl@0
|
670 |
|
sl@0
|
671 |
|
sl@0
|
672 |
r=TheFs.GetDir(sortSpec, KEntryAttNormal | KEntryAttDir, ESortByName | EDirsLast | EDescending, dirList);
|
sl@0
|
673 |
test(r==KErrNone);
|
sl@0
|
674 |
count=dirList->Count();
|
sl@0
|
675 |
test(count==numFiles);
|
sl@0
|
676 |
|
sl@0
|
677 |
|
sl@0
|
678 |
for (i = 0; i < count; i++)
|
sl@0
|
679 |
{
|
sl@0
|
680 |
test.Printf(KPrintFileName, &(*dirList)[i].iName);
|
sl@0
|
681 |
}
|
sl@0
|
682 |
|
sl@0
|
683 |
|
sl@0
|
684 |
entry=(*dirList)[0];
|
sl@0
|
685 |
test(entry.iName.FindF(KFileBS)>=0);
|
sl@0
|
686 |
entry=(*dirList)[1];
|
sl@0
|
687 |
test(entry.iName.FindF(KFileBB)>=0);
|
sl@0
|
688 |
entry=(*dirList)[2];
|
sl@0
|
689 |
test(entry.iName.FindF(KFileB)>=0);
|
sl@0
|
690 |
delete dirList;
|
sl@0
|
691 |
dirList = 0;
|
sl@0
|
692 |
|
sl@0
|
693 |
|
sl@0
|
694 |
DeleteTestDirectoryStructure(KSortByNamePath);
|
sl@0
|
695 |
}
|
sl@0
|
696 |
|
sl@0
|
697 |
|
sl@0
|
698 |
|
sl@0
|
699 |
//
|
sl@0
|
700 |
// Path and File names for sorting by extension
|
sl@0
|
701 |
//
|
sl@0
|
702 |
// The correctly sorted directory listing should be:
|
sl@0
|
703 |
//
|
sl@0
|
704 |
// sortext.a
|
sl@0
|
705 |
// sortext.bbb.a
|
sl@0
|
706 |
// sortext1.ddd.a
|
sl@0
|
707 |
// sortext.aaa.b
|
sl@0
|
708 |
// sortext.b
|
sl@0
|
709 |
// sortext.c
|
sl@0
|
710 |
// sortext.ccc.c
|
sl@0
|
711 |
//
|
sl@0
|
712 |
// as we should sort by the substring after the last '.'
|
sl@0
|
713 |
//
|
sl@0
|
714 |
_LIT(KSortByExtPath, "\\F32-TST\\TDIRS\\SORT_EXT\\");
|
sl@0
|
715 |
_LIT(KFile1, "sortext.aaa.b");
|
sl@0
|
716 |
_LIT(KFile2, "sortext.bbb.a");
|
sl@0
|
717 |
_LIT(KFile3, "sortext.ccc.c");
|
sl@0
|
718 |
_LIT(KFile4, "sortext1.ddd.a");
|
sl@0
|
719 |
_LIT(KFile5, "sortext.a");
|
sl@0
|
720 |
_LIT(KFile6, "sortext.b");
|
sl@0
|
721 |
_LIT(KFile7, "sortext.c");
|
sl@0
|
722 |
|
sl@0
|
723 |
|
sl@0
|
724 |
static void TestSortByExt()
|
sl@0
|
725 |
//
|
sl@0
|
726 |
// Test that sorting by extension works. This includes filenames
|
sl@0
|
727 |
// that contain multiple .'s
|
sl@0
|
728 |
//
|
sl@0
|
729 |
{
|
sl@0
|
730 |
const TDesC* theFiles[] = {&KFile1, &KFile2, &KFile3, &KFile4, &KFile5, &KFile6, &KFile7};
|
sl@0
|
731 |
TInt numFiles = sizeof(theFiles)/sizeof(theFiles[0]);
|
sl@0
|
732 |
CreateTestDirectoryStructure(KSortByExtPath, theFiles, numFiles);
|
sl@0
|
733 |
|
sl@0
|
734 |
test.Next(_L("Test ESortByExt"));
|
sl@0
|
735 |
|
sl@0
|
736 |
CDir* dirList;
|
sl@0
|
737 |
TBuf<128> sortSpec(KSortByExtPath);
|
sl@0
|
738 |
sortSpec.Append(KSortAll);
|
sl@0
|
739 |
TInt r=TheFs.GetDir(sortSpec, KEntryAttNormal | KEntryAttDir, ESortByExt | EDirsLast, dirList);
|
sl@0
|
740 |
test(r==KErrNone);
|
sl@0
|
741 |
TInt count=dirList->Count();
|
sl@0
|
742 |
test(count==numFiles);
|
sl@0
|
743 |
|
sl@0
|
744 |
|
sl@0
|
745 |
TInt i;
|
sl@0
|
746 |
for (i = 0; i < count; i++)
|
sl@0
|
747 |
{
|
sl@0
|
748 |
test.Printf(KPrintFileName, &(*dirList)[i].iName);
|
sl@0
|
749 |
}
|
sl@0
|
750 |
|
sl@0
|
751 |
|
sl@0
|
752 |
//
|
sl@0
|
753 |
// Verify that the files have been sorted correctly by extension
|
sl@0
|
754 |
//
|
sl@0
|
755 |
TEntry entry=(*dirList)[0];
|
sl@0
|
756 |
test(entry.iName.FindF(KFile5)>=0);
|
sl@0
|
757 |
entry=(*dirList)[1];
|
sl@0
|
758 |
test(entry.iName.FindF(KFile2)>=0);
|
sl@0
|
759 |
entry=(*dirList)[2];
|
sl@0
|
760 |
test(entry.iName.FindF(KFile4)>=0);
|
sl@0
|
761 |
entry=(*dirList)[3];
|
sl@0
|
762 |
test(entry.iName.FindF(KFile1)>=0);
|
sl@0
|
763 |
entry=(*dirList)[4];
|
sl@0
|
764 |
test(entry.iName.FindF(KFile6)>=0);
|
sl@0
|
765 |
entry=(*dirList)[5];
|
sl@0
|
766 |
test(entry.iName.FindF(KFile7)>=0);
|
sl@0
|
767 |
entry=(*dirList)[6];
|
sl@0
|
768 |
test(entry.iName.FindF(KFile3)>=0);
|
sl@0
|
769 |
delete dirList;
|
sl@0
|
770 |
dirList = 0;
|
sl@0
|
771 |
|
sl@0
|
772 |
|
sl@0
|
773 |
test.Next(_L("Test ESortByExt (descending)"));
|
sl@0
|
774 |
|
sl@0
|
775 |
r=TheFs.GetDir(sortSpec, KEntryAttNormal | KEntryAttDir, ESortByExt | EDirsLast | EDescending, dirList);
|
sl@0
|
776 |
test(r==KErrNone);
|
sl@0
|
777 |
count=dirList->Count();
|
sl@0
|
778 |
test(count==numFiles);
|
sl@0
|
779 |
|
sl@0
|
780 |
|
sl@0
|
781 |
for (i = 0; i < count; i++)
|
sl@0
|
782 |
{
|
sl@0
|
783 |
test.Printf(KPrintFileName, &(*dirList)[i].iName);
|
sl@0
|
784 |
}
|
sl@0
|
785 |
|
sl@0
|
786 |
|
sl@0
|
787 |
//
|
sl@0
|
788 |
// Verify that the files have been sorted correctly by extension
|
sl@0
|
789 |
// Note that this listing should be the reverse of that above.
|
sl@0
|
790 |
//
|
sl@0
|
791 |
entry=(*dirList)[0];
|
sl@0
|
792 |
test(entry.iName.FindF(KFile3)>=0);
|
sl@0
|
793 |
entry=(*dirList)[1];
|
sl@0
|
794 |
test(entry.iName.FindF(KFile7)>=0);
|
sl@0
|
795 |
entry=(*dirList)[2];
|
sl@0
|
796 |
test(entry.iName.FindF(KFile6)>=0);
|
sl@0
|
797 |
entry=(*dirList)[3];
|
sl@0
|
798 |
test(entry.iName.FindF(KFile1)>=0);
|
sl@0
|
799 |
entry=(*dirList)[4];
|
sl@0
|
800 |
test(entry.iName.FindF(KFile4)>=0);
|
sl@0
|
801 |
entry=(*dirList)[5];
|
sl@0
|
802 |
test(entry.iName.FindF(KFile2)>=0);
|
sl@0
|
803 |
entry=(*dirList)[6];
|
sl@0
|
804 |
test(entry.iName.FindF(KFile5)>=0);
|
sl@0
|
805 |
delete dirList;
|
sl@0
|
806 |
dirList = 0;
|
sl@0
|
807 |
|
sl@0
|
808 |
|
sl@0
|
809 |
DeleteTestDirectoryStructure(KSortByExtPath);
|
sl@0
|
810 |
}
|
sl@0
|
811 |
|
sl@0
|
812 |
//---------------------------------------------
|
sl@0
|
813 |
//! @SYMTestCaseID PBASE-T_DIRS-1310
|
sl@0
|
814 |
//! @SYMTestType CT
|
sl@0
|
815 |
//! @SYMREQ DEF125143
|
sl@0
|
816 |
//! @SYMTestCaseDesc Test that directory name is handled by File Server interfaces properly.
|
sl@0
|
817 |
//! @SYMTestActions Uses RFs::IsValidName(), RFs::MkDir(), RDir::Open(), RFs::RmDir() to test
|
sl@0
|
818 |
//! various dir name handling.
|
sl@0
|
819 |
//! @SYMTestExpectedResults Proper error code is returned.
|
sl@0
|
820 |
//! @SYMTestPriority High
|
sl@0
|
821 |
//! @SYMTestStatus Implemented
|
sl@0
|
822 |
//---------------------------------------------
|
sl@0
|
823 |
void TestDirNameHandling()
|
sl@0
|
824 |
{
|
sl@0
|
825 |
test.Next(_L("Test Dir Name Handling Interfaces"));
|
sl@0
|
826 |
TFileName dirTest1;
|
sl@0
|
827 |
dirTest1 = _L("\\F32-TST\\TDIRS\\test1\\FILE.TXT");
|
sl@0
|
828 |
TFileName dirTest2;
|
sl@0
|
829 |
dirTest2 = _L("\\F32-TST\\TDIRS\\test2.\\FILE.TXT");
|
sl@0
|
830 |
TFileName dirTest3;
|
sl@0
|
831 |
dirTest3 = _L("\\F32-TST\\TDIRS\\test3. \\FILE.TXT");
|
sl@0
|
832 |
TFileName dirTest4;
|
sl@0
|
833 |
dirTest4 = _L("\\F32-TST\\TDIRS\\test4. . \\FILE.TXT");
|
sl@0
|
834 |
TFileName dirTest5;
|
sl@0
|
835 |
dirTest5 = _L("\\F32-TST\\TDIRS\\test5.\\FILE.TXT");
|
sl@0
|
836 |
TFileName dirTest6;
|
sl@0
|
837 |
dirTest6 = _L("\\F32-TST\\TDIRS\\test6. .\\FILE.TXT");
|
sl@0
|
838 |
|
sl@0
|
839 |
TBool valid = TheFs.IsValidName( dirTest1 );
|
sl@0
|
840 |
test(valid);
|
sl@0
|
841 |
valid = TheFs.IsValidName( dirTest2 );
|
sl@0
|
842 |
test(!valid);
|
sl@0
|
843 |
valid = TheFs.IsValidName( dirTest3 );
|
sl@0
|
844 |
test(!valid);
|
sl@0
|
845 |
valid = TheFs.IsValidName( dirTest4 );
|
sl@0
|
846 |
test(!valid);
|
sl@0
|
847 |
valid = TheFs.IsValidName( dirTest5 );
|
sl@0
|
848 |
test(!valid);
|
sl@0
|
849 |
valid = TheFs.IsValidName( dirTest6 );
|
sl@0
|
850 |
test(!valid);
|
sl@0
|
851 |
|
sl@0
|
852 |
dirTest1 = _L("\\F32-TST\\TDIRS\\test1\\");
|
sl@0
|
853 |
dirTest2 = _L("\\F32-TST\\TDIRS\\test2.\\");
|
sl@0
|
854 |
dirTest3 = _L("\\F32-TST\\TDIRS\\test3. \\");
|
sl@0
|
855 |
dirTest4 = _L("\\F32-TST\\TDIRS\\test4. . \\");
|
sl@0
|
856 |
dirTest5 = _L("\\F32-TST\\TDIRS\\test5.\\");
|
sl@0
|
857 |
dirTest6 = _L("\\F32-TST\\TDIRS\\test6. .\\");
|
sl@0
|
858 |
|
sl@0
|
859 |
TInt err = TheFs.MkDir(dirTest1);
|
sl@0
|
860 |
test(err == KErrNone);
|
sl@0
|
861 |
err = TheFs.MkDir(dirTest2);
|
sl@0
|
862 |
test(err == KErrBadName);
|
sl@0
|
863 |
err = TheFs.MkDir(dirTest3);
|
sl@0
|
864 |
test(err == KErrBadName);
|
sl@0
|
865 |
err = TheFs.MkDir(dirTest4);
|
sl@0
|
866 |
test(err == KErrBadName);
|
sl@0
|
867 |
err = TheFs.MkDir(dirTest5);
|
sl@0
|
868 |
test(err == KErrBadName);
|
sl@0
|
869 |
err = TheFs.MkDir(dirTest6);
|
sl@0
|
870 |
test(err == KErrBadName);
|
sl@0
|
871 |
|
sl@0
|
872 |
RDir rdir;
|
sl@0
|
873 |
err = rdir.Open(TheFs, dirTest1, 0);
|
sl@0
|
874 |
rdir.Close();
|
sl@0
|
875 |
test(err == KErrNone);
|
sl@0
|
876 |
|
sl@0
|
877 |
err = rdir.Open(TheFs, dirTest2, 0);
|
sl@0
|
878 |
rdir.Close();
|
sl@0
|
879 |
test(err == KErrBadName);
|
sl@0
|
880 |
|
sl@0
|
881 |
err = rdir.Open(TheFs, dirTest3, 0);
|
sl@0
|
882 |
rdir.Close();
|
sl@0
|
883 |
test(err == KErrBadName);
|
sl@0
|
884 |
|
sl@0
|
885 |
err = rdir.Open(TheFs, dirTest4, 0);
|
sl@0
|
886 |
rdir.Close();
|
sl@0
|
887 |
test(err == KErrBadName);
|
sl@0
|
888 |
|
sl@0
|
889 |
err = rdir.Open(TheFs, dirTest5, 0);
|
sl@0
|
890 |
rdir.Close();
|
sl@0
|
891 |
test(err == KErrBadName);
|
sl@0
|
892 |
|
sl@0
|
893 |
err = rdir.Open(TheFs, dirTest6, 0);
|
sl@0
|
894 |
rdir.Close();
|
sl@0
|
895 |
test(err == KErrBadName);
|
sl@0
|
896 |
|
sl@0
|
897 |
err = TheFs.RmDir(dirTest1);
|
sl@0
|
898 |
test(err == KErrNone);
|
sl@0
|
899 |
err = TheFs.RmDir(dirTest2);
|
sl@0
|
900 |
test(err == KErrBadName);
|
sl@0
|
901 |
err = TheFs.RmDir(dirTest3);
|
sl@0
|
902 |
test(err == KErrBadName);
|
sl@0
|
903 |
err = TheFs.RmDir(dirTest4);
|
sl@0
|
904 |
test(err == KErrBadName);
|
sl@0
|
905 |
err = TheFs.RmDir(dirTest5);
|
sl@0
|
906 |
test(err == KErrBadName);
|
sl@0
|
907 |
err = TheFs.RmDir(dirTest6);
|
sl@0
|
908 |
test(err == KErrBadName);
|
sl@0
|
909 |
}
|
sl@0
|
910 |
|
sl@0
|
911 |
void CallTestsL()
|
sl@0
|
912 |
//
|
sl@0
|
913 |
// Do all tests
|
sl@0
|
914 |
//
|
sl@0
|
915 |
{
|
sl@0
|
916 |
|
sl@0
|
917 |
//-- set up console output
|
sl@0
|
918 |
F32_Test_Utils::SetConsole(test.Console());
|
sl@0
|
919 |
|
sl@0
|
920 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
|
sl@0
|
921 |
test(nRes==KErrNone);
|
sl@0
|
922 |
|
sl@0
|
923 |
PrintDrvInfo(TheFs, gDriveNum);
|
sl@0
|
924 |
|
sl@0
|
925 |
TurnAllocFailureOff();
|
sl@0
|
926 |
CreateTestDirectory(_L("\\F32-TST\\TDIRS\\"));
|
sl@0
|
927 |
|
sl@0
|
928 |
if (!gTestedZ)
|
sl@0
|
929 |
{
|
sl@0
|
930 |
TInt r=TheFs.SetSessionPath(_L("Z:\\"));
|
sl@0
|
931 |
test(r==KErrNone);
|
sl@0
|
932 |
Test2();
|
sl@0
|
933 |
TestZ();
|
sl@0
|
934 |
r=TheFs.SetSessionPath(gSessionPath);
|
sl@0
|
935 |
test(r==KErrNone);
|
sl@0
|
936 |
test.Next(_L("Run all other tests from \\F32-TST\\TDIRS\\"));
|
sl@0
|
937 |
gTestedZ=ETrue;
|
sl@0
|
938 |
}
|
sl@0
|
939 |
|
sl@0
|
940 |
Test8();
|
sl@0
|
941 |
|
sl@0
|
942 |
Test7();
|
sl@0
|
943 |
|
sl@0
|
944 |
Test1();
|
sl@0
|
945 |
Test2();
|
sl@0
|
946 |
Test3();
|
sl@0
|
947 |
Test4();
|
sl@0
|
948 |
Test5();
|
sl@0
|
949 |
Test6();
|
sl@0
|
950 |
Test9();
|
sl@0
|
951 |
|
sl@0
|
952 |
TestSortByName();
|
sl@0
|
953 |
TestSortByExt();
|
sl@0
|
954 |
TestDirNameHandling();
|
sl@0
|
955 |
|
sl@0
|
956 |
CleanupL();
|
sl@0
|
957 |
}
|