author | John Imhofe <john.imhofe@nokia.com> |
Mon, 21 Dec 2009 16:14:42 +0000 | |
changeset 15 | 4122176ea935 |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 1 |
/* |
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
0 | 3 |
* All rights reserved. |
4 |
* This component and the accompanying materials are made available |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
0 | 6 |
* which accompanies this distribution, and is available |
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
14 |
* Description: |
0 | 15 |
* |
16 |
*/ |
|
17 |
||
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
18 |
|
0 | 19 |
/** |
20 |
@test |
|
21 |
@internalComponent |
|
22 |
||
23 |
This contains CT_FsData |
|
24 |
*/ |
|
25 |
||
26 |
// User includes |
|
27 |
#include "T_FsData.h" |
|
28 |
#include "FileserverUtil.h" |
|
29 |
||
30 |
// EPOC includes |
|
31 |
#include <e32cmn.h> |
|
32 |
||
33 |
/*@{*/ |
|
34 |
||
35 |
// Parameters |
|
36 |
_LIT(KAttMask, "attmask" ); |
|
37 |
_LIT(KPath, "path"); |
|
38 |
_LIT(KDrive, "drive"); |
|
39 |
_LIT(KDir, "dir"); |
|
40 |
_LIT(KFile, "file"); |
|
41 |
_LIT(KName, "name"); |
|
42 |
_LIT(KNewName, "newname"); |
|
43 |
_LIT(KOldName, "oldname"); |
|
44 |
_LIT(KLongName, "longname"); |
|
45 |
_LIT(KShortName, "shortname"); |
|
46 |
_LIT(KLengthBuffer, "length_buffer"); |
|
47 |
_LIT(KLengthRead, "length_read"); |
|
48 |
_LIT(KEntrySortKey, "sortkey"); |
|
49 |
_LIT(KEntrySetAttMask, "setattmask"); |
|
50 |
_LIT(KEntryClearAttMask, "clearattmask"); |
|
51 |
_LIT(KTime, "time"); |
|
52 |
_LIT(KOffset, "offset"); |
|
53 |
_LIT(KTUidType, "uidtype"); |
|
54 |
_LIT(KIsDirList, "isdirlist"); |
|
55 |
_LIT(KRelated, "related"); |
|
56 |
_LIT(KBadChar, "badchar"); |
|
57 |
_LIT(KIsBadChar, "isbadchar"); |
|
58 |
_LIT(KCompareName, "comparename"); |
|
59 |
_LIT(KComparePath, "comparepath"); |
|
60 |
_LIT(KParseName, "parsename"); |
|
61 |
_LIT(KParseDrive, "parsedrive"); |
|
62 |
_LIT(KParsePath, "parsepath"); |
|
63 |
_LIT(KParseExt, "parseext"); |
|
64 |
_LIT(KIsExist, "isexist"); |
|
65 |
_LIT(KIsSetAtt, "issetatt"); |
|
66 |
_LIT(KSize, "size"); |
|
67 |
_LIT(KIsOpen, "isopen"); |
|
68 |
_LIT(KIsValid, "isvalid"); |
|
69 |
_LIT(KIsInRom, "isinrom"); |
|
70 |
_LIT(KDirEntryArray, "dirEntryObject"); |
|
71 |
_LIT(KDirDirectoryArray, "dirDirectoryObject"); |
|
72 |
_LIT(KObjectEntry, "entry" ); |
|
73 |
||
74 |
// Attributes for compare |
|
75 |
_LIT(KIsAttReadOnly, "isattreadonly"); |
|
76 |
_LIT(KIsAttHidden, "isatthidden"); |
|
77 |
_LIT(KIsAttSystem, "isattsystem"); |
|
78 |
_LIT(KIsAttDir, "isattdir"); |
|
79 |
_LIT(KIsAttArchive, "isattarchive"); |
|
80 |
_LIT(KIsAttAllowUid, "isattuid"); |
|
81 |
||
82 |
// Commands |
|
83 |
_LIT(KCmdRealName, "RealName"); |
|
84 |
_LIT(KCmdSessionPath, "SessionPath"); |
|
85 |
_LIT(KCmdSetSessionPath, "SetSessionPath"); |
|
86 |
_LIT(KCmdParse, "Parse"); |
|
87 |
_LIT(KCmdMkDir, "MkDir"); |
|
88 |
_LIT(KCmdMkDirAll, "MkDirAll"); |
|
89 |
_LIT(KCmdRmDir, "RmDir"); |
|
90 |
_LIT(KCmdGetDir, "GetDir"); |
|
91 |
_LIT(KCmdDelete, "Delete"); |
|
92 |
_LIT(KCmdRename, "Rename"); |
|
93 |
_LIT(KCmdReplace, "Replace"); |
|
94 |
_LIT(KCmdAtt, "Att"); |
|
95 |
_LIT(KCmdSetAtt, "SetAtt"); |
|
96 |
_LIT(KCmdModified, "Modified"); |
|
97 |
_LIT(KCmdSetModified, "SetModified"); |
|
98 |
_LIT(KCmdEntry, "Entry"); |
|
99 |
_LIT(KCmdSetEntry, "SetEntry"); |
|
100 |
_LIT(KCmdReadFileSection, "ReadFileSection"); |
|
101 |
_LIT(KCmdIsFileOpen, "IsFileOpen"); |
|
102 |
_LIT(KCmdGetShortName, "GetShortName"); |
|
103 |
_LIT(KCmdGetLongName, "GetLongName"); |
|
104 |
_LIT(KCmdIsFileInRom, "IsFileInRom"); |
|
105 |
_LIT(KCmdIsValidName, "IsValidName"); |
|
106 |
_LIT(KCmdSetSessionToPrivate, "SetSessionToPrivate"); |
|
107 |
_LIT(KCmdPrivatePath, "PrivatePath"); |
|
108 |
_LIT(KCmdCreatePrivatePath, "CreatePrivatePath"); |
|
109 |
||
110 |
// Sort key |
|
111 |
_LIT(KESortNone, "ESortNone"); |
|
112 |
_LIT(KESortByName, "ESortByName"); |
|
113 |
_LIT(KESortByExt, "ESortByExt"); |
|
114 |
_LIT(KESortBySize, "ESortBySize"); |
|
115 |
_LIT(KESortByDate, "ESortByDate"); |
|
116 |
_LIT(KESortByUid, "ESortByUid"); |
|
117 |
_LIT(KEDirsAnyOrder, "EDirsAnyOrder"); |
|
118 |
_LIT(KEDirsFirst, "EDirsFirst"); |
|
119 |
_LIT(KEDirsLast, "EDirsLast"); |
|
120 |
_LIT(KEAscending, "EAscending"); |
|
121 |
_LIT(KEDescending, "EDescending"); |
|
122 |
_LIT(KEDirDescending, "EDirDescending"); |
|
123 |
||
124 |
// Attributes |
|
125 |
_LIT(KEntryAttUnknown, "KEntryAttUnknown"); |
|
126 |
_LIT(KEntryAttReadOnlyStr, "KEntryAttReadOnly"); |
|
127 |
_LIT(KEntryAttHiddenStr, "KEntryAttHidden"); |
|
128 |
_LIT(KEntryAttSystemStr, "KEntryAttSystem"); |
|
129 |
_LIT(KEntryAttVolumeStr, "KEntryAttVolume"); |
|
130 |
_LIT(KEntryAttDirStr, "KEntryAttDir"); |
|
131 |
_LIT(KEntryAttArchiveStr, "KEntryAttArchive"); |
|
132 |
_LIT(KEntryAttAllowUidStr, "KEntryAttAllowUid"); |
|
133 |
_LIT(KEntryAttXIPStr, "KEntryAttXIP"); |
|
134 |
||
135 |
// Constants |
|
136 |
_LIT(KTimeFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); //SIZE 30 |
|
137 |
#define KTimeFormatSize 30 |
|
138 |
#define KShortNameSize 13 |
|
139 |
#define KLongNameSize 256 |
|
140 |
||
141 |
/*@}*/ |
|
142 |
||
143 |
/** |
|
144 |
* Process a files related command read from the ini file |
|
145 |
* |
|
146 |
* @param aCommand the command to process |
|
147 |
* @param aSection the entry in the ini file requiring the command to be processed |
|
148 |
* |
|
149 |
* @return ETrue if the command is processed |
|
150 |
*/ |
|
151 |
TBool CT_FsData::DoCommandFilesL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aSynchronous*/) |
|
152 |
{ |
|
153 |
TBool retVal = ETrue; |
|
154 |
||
155 |
if (aCommand == KCmdAtt) |
|
156 |
{ |
|
157 |
DoCmdAtt(aSection); |
|
158 |
} |
|
159 |
else if (aCommand == KCmdCreatePrivatePath) |
|
160 |
{ |
|
161 |
DoCmdCreatePrivatePath(aSection); |
|
162 |
} |
|
163 |
else if (aCommand == KCmdDelete) |
|
164 |
{ |
|
165 |
DoCmdDelete(aSection); |
|
166 |
} |
|
167 |
else if (aCommand == KCmdEntry) |
|
168 |
{ |
|
169 |
DoCmdEntryL(aSection); |
|
170 |
} |
|
171 |
else if (aCommand == KCmdGetDir) |
|
172 |
{ |
|
173 |
DoCmdGetDir(aSection); |
|
174 |
} |
|
175 |
else if (aCommand == KCmdGetShortName) |
|
176 |
{ |
|
177 |
DoCmdGetShortName(aSection); |
|
178 |
} |
|
179 |
else if (aCommand == KCmdGetLongName) |
|
180 |
{ |
|
181 |
DoCmdGetLongName(aSection); |
|
182 |
} |
|
183 |
else if (aCommand == KCmdIsFileInRom) |
|
184 |
{ |
|
185 |
DoCmdIsFileInRom(aSection); |
|
186 |
} |
|
187 |
else if (aCommand == KCmdIsFileOpen) |
|
188 |
{ |
|
189 |
DoCmdIsFileOpen(aSection); |
|
190 |
} |
|
191 |
else if (aCommand == KCmdIsValidName) |
|
192 |
{ |
|
193 |
DoCmdIsValidName(aSection); |
|
194 |
} |
|
195 |
else if (aCommand == KCmdMkDir) |
|
196 |
{ |
|
197 |
DoCmdMkDir(aSection); |
|
198 |
} |
|
199 |
else if (aCommand == KCmdMkDirAll) |
|
200 |
{ |
|
201 |
DoCmdMkDirAll(aSection); |
|
202 |
} |
|
203 |
else if (aCommand == KCmdModified) |
|
204 |
{ |
|
205 |
DoCmdModified(aSection); |
|
206 |
} |
|
207 |
else if (aCommand == KCmdParse) |
|
208 |
{ |
|
209 |
DoCmdParse(aSection); |
|
210 |
} |
|
211 |
else if (aCommand == KCmdPrivatePath) |
|
212 |
{ |
|
213 |
DoCmdPrivatePath(aSection); |
|
214 |
} |
|
215 |
else if (aCommand == KCmdReadFileSection) |
|
216 |
{ |
|
217 |
DoCmdReadFileSectionL(aSection); |
|
218 |
} |
|
219 |
else if (aCommand == KCmdRealName) |
|
220 |
{ |
|
221 |
DoCmdRealName(aSection); |
|
222 |
} |
|
223 |
else if (aCommand == KCmdRename) |
|
224 |
{ |
|
225 |
DoCmdRename(aSection); |
|
226 |
} |
|
227 |
else if (aCommand == KCmdReplace) |
|
228 |
{ |
|
229 |
DoCmdReplace(aSection); |
|
230 |
} |
|
231 |
else if (aCommand == KCmdRmDir) |
|
232 |
{ |
|
233 |
DoCmdRmDir(aSection); |
|
234 |
} |
|
235 |
else if (aCommand == KCmdSessionPath) |
|
236 |
{ |
|
237 |
DoCmdSessionPath(aSection); |
|
238 |
} |
|
239 |
else if (aCommand == KCmdSetAtt) |
|
240 |
{ |
|
241 |
DoCmdSetAtt(aSection); |
|
242 |
} |
|
243 |
else if (aCommand == KCmdSetEntry) |
|
244 |
{ |
|
245 |
DoCmdSetEntry(aSection); |
|
246 |
} |
|
247 |
else if (aCommand == KCmdSetModified) |
|
248 |
{ |
|
249 |
DoCmdSetModified(aSection); |
|
250 |
} |
|
251 |
else if (aCommand == KCmdSetSessionPath) |
|
252 |
{ |
|
253 |
DoCmdSetSessionPath(aSection); |
|
254 |
} |
|
255 |
else if (aCommand == KCmdSetSessionToPrivate) |
|
256 |
{ |
|
257 |
DoCmdSetSessionToPrivate(aSection); |
|
258 |
} |
|
259 |
else |
|
260 |
{ |
|
261 |
retVal = EFalse; |
|
262 |
} |
|
263 |
||
264 |
return retVal; |
|
265 |
} |
|
266 |
||
267 |
void CT_FsData::DoCmdRealName(const TDesC& aSection) |
|
268 |
{ |
|
269 |
// Gets name of file from ini file. |
|
270 |
TPtrC name; |
|
271 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
272 |
{ |
|
273 |
// Gets the real name of a file. |
|
274 |
TFileName realName; |
|
275 |
TInt err = iFs->RealName(name, realName); |
|
276 |
if (err != KErrNone) |
|
277 |
{ |
|
278 |
ERR_PRINTF2(_L("RealName error %d"), err); |
|
279 |
SetError(err); |
|
280 |
} |
|
281 |
else |
|
282 |
{ |
|
283 |
// Prints real name. |
|
284 |
INFO_PRINTF2(_L("Real name: %S"), &realName); |
|
285 |
||
286 |
// Compares realname from ini file and realname from function. |
|
287 |
TPtrC compareName; |
|
288 |
if (GET_OPTIONAL_STRING_PARAMETER(KCompareName(), aSection, compareName)) |
|
289 |
{ |
|
290 |
if (compareName.CompareC(realName, 0, NULL) != 0) |
|
291 |
{ |
|
292 |
ERR_PRINTF3(_L("Error compare %S != %S"), &realName, &compareName); |
|
293 |
SetBlockResult(EFail); |
|
294 |
} |
|
295 |
else |
|
296 |
{ |
|
297 |
INFO_PRINTF3(_L("%S == %S"), &realName, &compareName); |
|
298 |
} |
|
299 |
} |
|
300 |
} |
|
301 |
} |
|
302 |
} |
|
303 |
||
304 |
void CT_FsData::DoCmdSessionPath(const TDesC& aSection) |
|
305 |
{ |
|
306 |
// Gets the session path. |
|
307 |
TBuf<KMaxTestExecuteCommandLength> path; |
|
308 |
TInt err = iFs->SessionPath(path); |
|
309 |
if (err != KErrNone) |
|
310 |
{ |
|
311 |
ERR_PRINTF2(_L("SessionPath error %d"), err); |
|
312 |
SetError(err); |
|
313 |
} |
|
314 |
else |
|
315 |
{ |
|
316 |
// Prints session path. |
|
317 |
INFO_PRINTF2(_L("Session path is %S"), &path); |
|
318 |
||
319 |
// Compares path from ini file and path from function. |
|
320 |
TPtrC comparePath; |
|
321 |
if (GET_OPTIONAL_STRING_PARAMETER(KComparePath(), aSection, comparePath)) |
|
322 |
{ |
|
323 |
if (comparePath.CompareC(path, 0, NULL) != 0) |
|
324 |
{ |
|
325 |
ERR_PRINTF3(_L("Error compare %S != %S"), &path, &comparePath); |
|
326 |
SetBlockResult(EFail); |
|
327 |
} |
|
328 |
else |
|
329 |
{ |
|
330 |
INFO_PRINTF3(_L("%S == %S"), &path, &comparePath); |
|
331 |
} |
|
332 |
} |
|
333 |
} |
|
334 |
} |
|
335 |
||
336 |
void CT_FsData::DoCmdSetSessionPath(const TDesC& aSection) |
|
337 |
{ |
|
338 |
// Gets path from ini file. |
|
339 |
TPtrC path; |
|
340 |
if (GET_MANDATORY_STRING_PARAMETER(KPath(), aSection, path)) |
|
341 |
{ |
|
342 |
// Sets the session path for the current file server client. |
|
343 |
TInt err = iFs->SetSessionPath(path); |
|
344 |
if (err != KErrNone) |
|
345 |
{ |
|
346 |
ERR_PRINTF2(_L("SetSessionPath error %d"), err); |
|
347 |
SetError(err); |
|
348 |
} |
|
349 |
else |
|
350 |
{ |
|
351 |
// Prints session path. |
|
352 |
INFO_PRINTF2(_L("Path is set into %S"), &path); |
|
353 |
} |
|
354 |
} |
|
355 |
} |
|
356 |
||
357 |
void CT_FsData::DoCmdParse(const TDesC& aSection) |
|
358 |
{ |
|
359 |
// Gets name of file from ini file. |
|
360 |
TPtrC name; |
|
361 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
362 |
{ |
|
363 |
TInt err; |
|
364 |
TParse parse; |
|
365 |
TPtrC related; |
|
366 |
||
367 |
// Reads the related file specification. |
|
368 |
if (GET_OPTIONAL_STRING_PARAMETER(KRelated(), aSection, related)) |
|
369 |
{ |
|
370 |
INFO_PRINTF2(_L("Related parameter: %S"), &related); |
|
371 |
||
372 |
// Parses a filename specification, specifying related file path components. |
|
373 |
err = iFs->Parse(name, related, parse); |
|
374 |
} |
|
375 |
else |
|
376 |
{ |
|
377 |
// Parses a filename specification. |
|
378 |
err = iFs->Parse(name, parse); |
|
379 |
} |
|
380 |
||
381 |
if (err != KErrNone) |
|
382 |
{ |
|
383 |
ERR_PRINTF2(_L("Parse error %d"), err); |
|
384 |
SetError(err); |
|
385 |
} |
|
386 |
else |
|
387 |
{ |
|
388 |
// Writes parsed components to log file. |
|
389 |
TPtrC parsedResult[] = |
|
390 |
{ |
|
391 |
parse.Drive(), //parsedDrive, |
|
392 |
parse.Path(), //parsedPath, |
|
393 |
parse.Name(), //parsedName, |
|
394 |
parse.Ext() //parsedExt, |
|
395 |
};// size 4 |
|
396 |
||
397 |
TBuf<KMaxTestExecuteCommandLength> tempStore; |
|
398 |
tempStore.Format(_L("Parsed %S, Drive: %S, Path: %S, Name: %S, Ext: %S"), &name, |
|
399 |
&parsedResult[0], //Drive |
|
400 |
&parsedResult[1], //Path |
|
401 |
&parsedResult[2], //Name |
|
402 |
&parsedResult[3]);//Ext |
|
403 |
INFO_PRINTF1(tempStore); |
|
404 |
||
405 |
||
406 |
// Compares parsed components from ini file. |
|
407 |
TPtrC iniParsed[] = |
|
408 |
{ |
|
409 |
KParseDrive(), |
|
410 |
KParsePath(), |
|
411 |
KParseName(), |
|
412 |
KParseExt() |
|
413 |
};// size 4 |
|
414 |
||
415 |
TInt size = sizeof(iniParsed) / sizeof(TPtrC); |
|
416 |
for (TInt i = 0; i < size; i++) |
|
417 |
{ |
|
418 |
// Reads components from ini |
|
419 |
TPtrC compareName; |
|
420 |
if (GET_OPTIONAL_STRING_PARAMETER(iniParsed[i], aSection, compareName)) |
|
421 |
{ |
|
422 |
if (parsedResult[i].CompareC(compareName, 0, NULL) != 0) |
|
423 |
{ |
|
424 |
ERR_PRINTF3(_L("Error compare %S != %S"), &parsedResult[i], &compareName); |
|
425 |
SetBlockResult(EFail); |
|
426 |
} |
|
427 |
else |
|
428 |
{ |
|
429 |
INFO_PRINTF3(_L("%S == %S"), &parsedResult[i], &compareName); |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
} |
|
434 |
} |
|
435 |
} |
|
436 |
||
437 |
void CT_FsData::DoCmdMkDir(const TDesC& aSection) |
|
438 |
{ |
|
439 |
// Gets name of directiry from ini file. |
|
440 |
TPtrC dir; |
|
441 |
if (GET_MANDATORY_STRING_PARAMETER(KDir(), aSection, dir)) |
|
442 |
{ |
|
443 |
// Makes a directory. |
|
444 |
TInt err = iFs->MkDir(dir); |
|
445 |
if (err != KErrNone) |
|
446 |
{ |
|
447 |
ERR_PRINTF2(_L("MkDir error %d"), err); |
|
448 |
SetError(err); |
|
449 |
} |
|
450 |
} |
|
451 |
} |
|
452 |
||
453 |
void CT_FsData::DoCmdMkDirAll(const TDesC& aSection) |
|
454 |
{ |
|
455 |
// Gets name of directiry from ini file. |
|
456 |
TPtrC dir; |
|
457 |
if (GET_MANDATORY_STRING_PARAMETER(KDir(), aSection, dir)) |
|
458 |
{ |
|
459 |
// Makes one or more directories. |
|
460 |
TInt err = iFs->MkDirAll(dir); |
|
461 |
if (err != KErrNone) |
|
462 |
{ |
|
463 |
ERR_PRINTF2(_L("MkDirAll error %d"), err); |
|
464 |
SetError(err); |
|
465 |
} |
|
466 |
} |
|
467 |
} |
|
468 |
||
469 |
void CT_FsData::DoCmdRmDir(const TDesC& aSection) |
|
470 |
{ |
|
471 |
// Gets name of directiry from ini file. |
|
472 |
TPtrC dir; |
|
473 |
if (GET_MANDATORY_STRING_PARAMETER(KDir(), aSection, dir)) |
|
474 |
{ |
|
475 |
// Removes a directory. |
|
476 |
TInt err = iFs->RmDir(dir); |
|
477 |
if (err != KErrNone) |
|
478 |
{ |
|
479 |
ERR_PRINTF2(_L("RmDir error %d"), err); |
|
480 |
SetError(err); |
|
481 |
} |
|
482 |
} |
|
483 |
} |
|
484 |
||
485 |
void CT_FsData::DoCmdGetDir(const TDesC& aSection) |
|
486 |
{ |
|
487 |
TBool dataOk = ETrue; |
|
488 |
||
489 |
// Reads name of directory from ini file. |
|
490 |
TPtrC name; |
|
491 |
if (!GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
492 |
{ |
|
493 |
dataOk = EFalse; |
|
494 |
} |
|
495 |
||
496 |
// Reads sort key from ini file. |
|
497 |
TPtrC entrySortKey; |
|
498 |
TUint sortKey = ESortByName; |
|
499 |
if (GET_MANDATORY_STRING_PARAMETER(KEntrySortKey(), aSection, entrySortKey)) |
|
500 |
{ |
|
501 |
if ( !ConvertToSortKey(entrySortKey, sortKey) ) |
|
502 |
{ |
|
503 |
TInt intTemp; |
|
504 |
if ( GET_MANDATORY_INT_PARAMETER(KEntrySortKey(), aSection, intTemp) ) |
|
505 |
{ |
|
506 |
sortKey=intTemp; |
|
507 |
} |
|
508 |
else |
|
509 |
{ |
|
510 |
dataOk = EFalse; |
|
511 |
} |
|
512 |
} |
|
513 |
} |
|
514 |
else |
|
515 |
{ |
|
516 |
dataOk = EFalse; |
|
517 |
} |
|
518 |
||
519 |
// Reads attribute mask from ini file |
|
520 |
// if not exist |
|
521 |
// Reads uidtype from ini file |
|
522 |
||
523 |
TInt intUIDType = 0; |
|
524 |
TUidType uidType = KNullUid; |
|
525 |
TBool isUidType = EFalse; |
|
526 |
||
527 |
TUint attMask = KEntryAttNormal; |
|
528 |
||
529 |
TBool isDirList = FALSE; |
|
530 |
||
531 |
if (FileserverUtil::GetAttMask(*this, aSection, KAttMask(), attMask)) |
|
532 |
{ |
|
533 |
// Reads boolean of dirlist from ini file. |
|
534 |
GET_OPTIONAL_BOOL_PARAMETER(KIsDirList(), aSection, isDirList); |
|
535 |
} |
|
536 |
else if (GET_MANDATORY_INT_PARAMETER(KTUidType(), aSection, intUIDType)) |
|
537 |
{ |
|
538 |
TUid id = TUid::Uid(intUIDType); |
|
539 |
uidType = TUidType(id); |
|
540 |
INFO_PRINTF2(_L("UID type set to %d"), uidType[0].iUid); |
|
541 |
} |
|
542 |
else |
|
543 |
{ |
|
544 |
dataOk = EFalse; |
|
545 |
ERR_PRINTF2(_L("attmask or %S must be declared !!!"), &KTUidType); |
|
546 |
} |
|
547 |
||
548 |
// If all data was read |
|
549 |
if (dataOk) |
|
550 |
{ |
|
551 |
// Gets a filtered list of a directory's contents. |
|
552 |
TInt err = KErrNone; |
|
553 |
CT_DirData* dirWrapperEntry = NULL; |
|
554 |
CT_DirData* dirWrapperDirectory = NULL; |
|
555 |
CDir* entryArray = NULL; |
|
556 |
CDir* dirArray = NULL; |
|
557 |
TPtrC dirEntryArray; |
|
558 |
TPtrC dirDirectoryArray; |
|
559 |
||
560 |
if (GET_OPTIONAL_STRING_PARAMETER(KDirEntryArray(), aSection, dirEntryArray)) |
|
561 |
{ |
|
562 |
TRAP(err, dirWrapperEntry = static_cast<CT_DirData*>(GetDataWrapperL(dirEntryArray))); |
|
563 |
} |
|
564 |
||
565 |
if (GET_OPTIONAL_STRING_PARAMETER(KDirDirectoryArray(), aSection, dirDirectoryArray)) |
|
566 |
{ |
|
567 |
TRAP(err, dirWrapperDirectory = static_cast<CT_DirData*>(GetDataWrapperL(dirDirectoryArray))); |
|
568 |
} |
|
569 |
||
570 |
if (isUidType) |
|
571 |
{ |
|
572 |
// Gets a filtered list of a directory's contents by UID type. |
|
573 |
err = iFs->GetDir(name, uidType, sortKey, entryArray); |
|
574 |
} |
|
575 |
else |
|
576 |
{ |
|
577 |
if (isDirList) |
|
578 |
{ |
|
579 |
// Gets a filtered list of the directory and file entries contained in a directory, |
|
580 |
// and a list of the directory entries only. |
|
581 |
err = iFs->GetDir(name, attMask, sortKey, entryArray, dirArray); |
|
582 |
} |
|
583 |
else |
|
584 |
{ |
|
585 |
// Gets a filtered list of a directory's contents. |
|
586 |
err = iFs->GetDir(name, attMask, sortKey, entryArray); |
|
587 |
} |
|
588 |
} |
|
589 |
||
590 |
if (err != KErrNone) |
|
591 |
{ |
|
592 |
ERR_PRINTF2(_L("GetDir error %d"), err); |
|
593 |
SetError(err); |
|
594 |
} |
|
595 |
else |
|
596 |
{ |
|
597 |
// Writes sorted entries to log file. |
|
598 |
INFO_PRINTF2(_L("PATH %S"), &name); |
|
599 |
for (TInt i = 0; i < entryArray->Count(); i++) |
|
600 |
{ |
|
601 |
TBuf<KMaxTestExecuteCommandLength> tempStore; |
|
602 |
tempStore.Format(_L("%d) %S"), i+1, &(*entryArray)[i].iName); |
|
603 |
INFO_PRINTF1(tempStore); |
|
604 |
} |
|
605 |
||
606 |
// If "_comparename" of parameter is set in INI file, then |
|
607 |
// try to find this name in the list of entries. |
|
608 |
TPtrC compareName; |
|
609 |
if (GET_OPTIONAL_STRING_PARAMETER(KCompareName(), aSection, compareName)) |
|
610 |
{ |
|
611 |
// Find compare name in list of entries. |
|
612 |
TBool isFind = FALSE; |
|
613 |
for (TInt i = 0; i < entryArray->Count(); i++) |
|
614 |
{ |
|
615 |
if (compareName.CompareC((*entryArray)[i].iName, 0, NULL) == 0) |
|
616 |
{ |
|
617 |
isFind = TRUE; |
|
618 |
} |
|
619 |
} |
|
620 |
||
621 |
// Reads a flag which specifies a name should be existing or not be existing |
|
622 |
// specified in parameter "KCompareName". |
|
623 |
TBool isExist = TRUE; |
|
624 |
GET_OPTIONAL_BOOL_PARAMETER(KIsExist(), aSection, isExist); |
|
625 |
||
626 |
TPtrC strIsExist = isExist ? _L("EXIST") : _L("NOT EXIST"); |
|
627 |
INFO_PRINTF3(_L("%S must be %S"), &compareName, &strIsExist); |
|
628 |
||
629 |
TPtrC strIsFind = isFind ? _L("FOUND") : _L("NOT FOUND"); |
|
630 |
INFO_PRINTF3(_L("%S is %S"), &compareName, &strIsFind); |
|
631 |
||
632 |
// If name has been found when this name must not be existing |
|
633 |
// or when name has been not found when name must be existing |
|
634 |
// then test case fail. |
|
635 |
if (isExist != isFind) |
|
636 |
{ |
|
637 |
ERR_PRINTF1(_L("Expected exist does not match actual")); |
|
638 |
SetBlockResult(EFail); |
|
639 |
} |
|
640 |
} |
|
641 |
} |
|
642 |
||
643 |
// Delete list of data |
|
644 |
if (entryArray) |
|
645 |
{ |
|
646 |
if(dirWrapperEntry) |
|
647 |
{ |
|
648 |
dirWrapperEntry->SetObjectL(entryArray); |
|
649 |
} |
|
650 |
else |
|
651 |
{ |
|
652 |
delete entryArray; |
|
653 |
entryArray = NULL; |
|
654 |
} |
|
655 |
} |
|
656 |
if (dirArray) |
|
657 |
{ |
|
658 |
if(dirWrapperDirectory) |
|
659 |
{ |
|
660 |
dirWrapperDirectory->SetObjectL(dirArray); |
|
661 |
} |
|
662 |
else |
|
663 |
{ |
|
664 |
delete dirArray; |
|
665 |
dirArray = NULL; |
|
666 |
} |
|
667 |
} |
|
668 |
} |
|
669 |
} |
|
670 |
||
671 |
void CT_FsData::DoCmdDelete(const TDesC& aSection) |
|
672 |
{ |
|
673 |
// Reads name of file from ini file. |
|
674 |
TPtrC name; |
|
675 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
676 |
{ |
|
677 |
// Deletes a single file. |
|
678 |
TInt err = iFs->Delete(name); |
|
679 |
if (err != KErrNone) |
|
680 |
{ |
|
681 |
ERR_PRINTF2(_L("Delete error %d"), err); |
|
682 |
SetError(err); |
|
683 |
} |
|
684 |
} |
|
685 |
} |
|
686 |
||
687 |
void CT_FsData::DoCmdRename(const TDesC& aSection) |
|
688 |
{ |
|
689 |
TBool dataOk=ETrue; |
|
690 |
||
691 |
// Reads the old name of file or directory from ini file. |
|
692 |
TPtrC oldName; |
|
693 |
if ( !GET_MANDATORY_STRING_PARAMETER(KOldName(), aSection, oldName) ) |
|
694 |
{ |
|
695 |
dataOk=EFalse; |
|
696 |
} |
|
697 |
||
698 |
// Reads the new name of file or directory from ini file. |
|
699 |
TPtrC newName; |
|
700 |
if ( !GET_MANDATORY_STRING_PARAMETER(KNewName(), aSection, newName) ) |
|
701 |
{ |
|
702 |
dataOk=EFalse; |
|
703 |
} |
|
704 |
||
705 |
if ( dataOk ) |
|
706 |
{ |
|
707 |
// Renames a single file or directory. |
|
708 |
TInt err = iFs->Rename(oldName, newName); |
|
709 |
if (err != KErrNone) |
|
710 |
{ |
|
711 |
ERR_PRINTF2(_L("Rename error %d"), err); |
|
712 |
SetError(err); |
|
713 |
} |
|
714 |
else |
|
715 |
{ |
|
716 |
INFO_PRINTF3(_L("File %S was renamed to %S successfully"), &oldName, &newName); |
|
717 |
} |
|
718 |
} |
|
719 |
} |
|
720 |
||
721 |
void CT_FsData::DoCmdReplace(const TDesC& aSection) |
|
722 |
{ |
|
723 |
TBool dataOk=ETrue; |
|
724 |
||
725 |
// Reads the old name of file from ini file. |
|
726 |
TPtrC oldName; |
|
727 |
if ( !GET_MANDATORY_STRING_PARAMETER(KOldName(), aSection, oldName) ) |
|
728 |
{ |
|
729 |
dataOk=EFalse; |
|
730 |
} |
|
731 |
||
732 |
// Reads the new name of file from ini file. |
|
733 |
TPtrC newName; |
|
734 |
if ( !GET_MANDATORY_STRING_PARAMETER(KNewName(), aSection, newName) ) |
|
735 |
{ |
|
736 |
dataOk=EFalse; |
|
737 |
} |
|
738 |
||
739 |
if ( dataOk ) |
|
740 |
{ |
|
741 |
// Replaces a single file with another. |
|
742 |
TInt err = iFs->Replace(oldName, newName); |
|
743 |
if (err != KErrNone) |
|
744 |
{ |
|
745 |
ERR_PRINTF2(_L("Replace error %d"), err); |
|
746 |
SetError(err); |
|
747 |
} |
|
748 |
else |
|
749 |
{ |
|
750 |
INFO_PRINTF3(_L("File %S was replaced to %S successfully"), &oldName, &newName); |
|
751 |
} |
|
752 |
} |
|
753 |
} |
|
754 |
||
755 |
void CT_FsData::DoCmdAtt(const TDesC& aSection) |
|
756 |
{ |
|
757 |
// Reads the name of file from ini file. |
|
758 |
TPtrC name; |
|
759 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
760 |
{ |
|
761 |
// Gets a file's attributes. |
|
762 |
TUint attValue; |
|
763 |
TInt err = iFs->Att(name, attValue); |
|
764 |
INFO_PRINTF2(_L("RFs::Att = 0x%X"), attValue); |
|
765 |
if (err != KErrNone) |
|
766 |
{ |
|
767 |
ERR_PRINTF2(_L("Att error %d"), err); |
|
768 |
SetError(err); |
|
769 |
} |
|
770 |
else |
|
771 |
{ |
|
772 |
TUint arrAttMask[]= |
|
773 |
{ |
|
774 |
KEntryAttReadOnly, |
|
775 |
KEntryAttHidden, |
|
776 |
KEntryAttSystem, |
|
777 |
KEntryAttVolume, |
|
778 |
KEntryAttDir, |
|
779 |
KEntryAttArchive, |
|
780 |
KEntryAttXIP |
|
781 |
};//size 7 |
|
782 |
||
783 |
// Writes what attributes has a file. |
|
784 |
INFO_PRINTF1(_L("--- START --- print all attributes")); |
|
785 |
||
786 |
TInt size = sizeof(arrAttMask) / sizeof(TUint); |
|
787 |
for (TInt i = 0; i < size; i++) |
|
788 |
{ |
|
789 |
if (attValue & arrAttMask[i]) |
|
790 |
{ |
|
791 |
INFO_PRINTF2(_L("Attribute %S is set"), &ConvertToStrAttMask(arrAttMask[i])); |
|
792 |
} |
|
793 |
else |
|
794 |
{ |
|
795 |
INFO_PRINTF2(_L("Attribute %S is not set"), &ConvertToStrAttMask(arrAttMask[i])); |
|
796 |
} |
|
797 |
} |
|
798 |
INFO_PRINTF1(_L("--- END --- print all attributes")); |
|
799 |
||
800 |
// Reads atribute wich is testing. |
|
801 |
TPtrC testAttMaskStr; |
|
802 |
if(GET_OPTIONAL_STRING_PARAMETER(KEntrySetAttMask(), aSection, testAttMaskStr)) |
|
803 |
{ |
|
804 |
TUint testAttMask = 0; |
|
805 |
if (FileserverUtil::GetAttMask(*this, aSection, KEntrySetAttMask(), testAttMask)) |
|
806 |
{ |
|
807 |
// Reads a flag which specifies a attribute should be set or not set |
|
808 |
// specified in parameter "KEntrySetAttMask". |
|
809 |
TBool testIsSet = TRUE; |
|
810 |
if (GET_OPTIONAL_BOOL_PARAMETER(KIsSetAtt(), aSection, testIsSet)) |
|
811 |
{ |
|
812 |
INFO_PRINTF2(_L("TEST attributes %S must be set"), &ConvertToStrAttMask(testAttMask)); |
|
813 |
} |
|
814 |
else |
|
815 |
{ |
|
816 |
INFO_PRINTF2(_L("TEST attributes %S must not be set"), &ConvertToStrAttMask(testAttMask)); |
|
817 |
} |
|
818 |
if ( (attValue&testAttMask)==testAttMask ) |
|
819 |
{ |
|
820 |
if ( !testIsSet ) |
|
821 |
{ |
|
822 |
ERR_PRINTF2(_L("All bits not set %S"), &ConvertToStrAttMask(testAttMask)); |
|
823 |
SetBlockResult(EFail); |
|
824 |
} |
|
825 |
} |
|
826 |
else if ( (attValue&testAttMask)==0 ) |
|
827 |
{ |
|
828 |
if ( testIsSet ) |
|
829 |
{ |
|
830 |
ERR_PRINTF2(_L("Some bits set %S"), &ConvertToStrAttMask(testAttMask)); |
|
831 |
SetBlockResult(EFail); |
|
832 |
} |
|
833 |
} |
|
834 |
else |
|
835 |
{ |
|
836 |
ERR_PRINTF2(_L("Some bits set %S"), &ConvertToStrAttMask(testAttMask)); |
|
837 |
SetBlockResult(EFail); |
|
838 |
} |
|
839 |
} |
|
840 |
else |
|
841 |
{ |
|
842 |
ERR_PRINTF1(_L("Unknown attribute!")); |
|
843 |
SetBlockResult(EFail); |
|
844 |
} |
|
845 |
} |
|
846 |
} |
|
847 |
} |
|
848 |
} |
|
849 |
||
850 |
void CT_FsData::DoCmdSetAtt(const TDesC& aSection) |
|
851 |
{ |
|
852 |
// Reads attributes to be set from ini file. |
|
853 |
TUint setAttMask = 0; |
|
854 |
||
855 |
if (!FileserverUtil::GetAttMask(*this, aSection, KEntrySetAttMask(), setAttMask)) |
|
856 |
{ |
|
857 |
ERR_PRINTF1(_L("Unknown attribute!")); |
|
858 |
SetBlockResult(EFail); |
|
859 |
} |
|
860 |
||
861 |
// Reads attributes to be clear from ini file. |
|
862 |
TUint clearAttMask = 0; |
|
863 |
if (!FileserverUtil::GetAttMask(*this, aSection, KEntryClearAttMask(), clearAttMask)) |
|
864 |
{ |
|
865 |
ERR_PRINTF1(_L("Unknown attribute!")); |
|
866 |
SetBlockResult(EFail); |
|
867 |
} |
|
868 |
||
869 |
// Reads the name of file or directory from ini file. |
|
870 |
TPtrC name; |
|
871 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
872 |
{ |
|
873 |
// Sets or clears the attributes of a single file or directory. |
|
874 |
TInt err = iFs->SetAtt(name, setAttMask, clearAttMask); |
|
875 |
if (err != KErrNone) |
|
876 |
{ |
|
877 |
ERR_PRINTF2(_L("SetAtt error %d"), err); |
|
878 |
SetError(err); |
|
879 |
} |
|
880 |
else |
|
881 |
{ |
|
882 |
INFO_PRINTF1(_L("SetAtt() is successful")); |
|
883 |
} |
|
884 |
} |
|
885 |
} |
|
886 |
||
887 |
void CT_FsData::DoCmdModified(const TDesC& aSection) |
|
888 |
{ |
|
889 |
// Reads the name of file or directory from ini file. |
|
890 |
TPtrC name; |
|
891 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
892 |
{ |
|
893 |
// Gets the last modification date and time of a file or a directory, in UTC. |
|
894 |
TTime time; |
|
895 |
TInt err = iFs->Modified(name, time); |
|
896 |
if (err != KErrNone) |
|
897 |
{ |
|
898 |
ERR_PRINTF2(_L("Modified error %d"), err); |
|
899 |
SetError(err); |
|
900 |
} |
|
901 |
else |
|
902 |
{ |
|
903 |
// Write to log modified date and time. |
|
904 |
TBuf<KTimeFormatSize> dateString; |
|
905 |
TRAP (err, time.FormatL(dateString, KTimeFormat)); |
|
906 |
if (err != KErrNone) |
|
907 |
{ |
|
908 |
ERR_PRINTF2(_L("time.FormatL() error %d"), err); |
|
909 |
SetBlockResult(EFail); |
|
910 |
} |
|
911 |
else |
|
912 |
{ |
|
913 |
INFO_PRINTF3(_L("File %S modified: %S"), &name, &dateString); |
|
914 |
||
915 |
// Reads time in ini file which must be returned from function "Modified()". |
|
916 |
TPtrC inputTime; |
|
917 |
if (GET_OPTIONAL_STRING_PARAMETER(KTime(), aSection, inputTime)) |
|
918 |
{ |
|
919 |
// Convert input string in "KTime" from ini to TTime object. |
|
920 |
// Assigns a date and time contained in a descriptor. |
|
921 |
TTime iniTime; |
|
922 |
TInt err = iniTime.Set(inputTime); |
|
923 |
if (err == KErrNone) |
|
924 |
{ |
|
925 |
// Compares time from ini file and time returned from function. |
|
926 |
if (iniTime == time) |
|
927 |
{ |
|
928 |
INFO_PRINTF1(_L("Time equal")); |
|
929 |
} |
|
930 |
else |
|
931 |
{ |
|
932 |
ERR_PRINTF3(_L("Time not equal, %S != %S"), &inputTime, &dateString); |
|
933 |
SetBlockResult(EFail); |
|
934 |
} |
|
935 |
} |
|
936 |
else |
|
937 |
{ |
|
938 |
ERR_PRINTF2(_L("Fail set time, error %d"), err); |
|
939 |
SetBlockResult(EFail); |
|
940 |
} |
|
941 |
} |
|
942 |
} |
|
943 |
} |
|
944 |
} |
|
945 |
} |
|
946 |
||
947 |
void CT_FsData::DoCmdSetModified(const TDesC& aSection) |
|
948 |
{ |
|
949 |
// Reads the time from ini file. |
|
950 |
TTime time(0); |
|
951 |
TPtrC inputTime; |
|
952 |
if (GET_OPTIONAL_STRING_PARAMETER(KTime(), aSection, inputTime)) |
|
953 |
{ |
|
954 |
// Assigns a date and time contained in a descriptor. |
|
955 |
TInt err = time.Set(inputTime); |
|
956 |
if (err != KErrNone) |
|
957 |
{ |
|
958 |
ERR_PRINTF2(_L("Time set failed, error %d"), err); |
|
959 |
SetBlockResult(EFail); |
|
960 |
} |
|
961 |
} |
|
962 |
||
963 |
// Reads the name of file or directory from ini file. |
|
964 |
TPtrC name; |
|
965 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
966 |
{ |
|
967 |
// Sets the date and time that the contents of a file or directory were modified, in UTC. |
|
968 |
TInt err = iFs->SetModified(name, time); |
|
969 |
if (err != KErrNone) |
|
970 |
{ |
|
971 |
ERR_PRINTF2(_L("SetModified error %d"), err); |
|
972 |
SetError(err); |
|
973 |
} |
|
974 |
else |
|
975 |
{ |
|
976 |
INFO_PRINTF1(_L("SetModified() OK")); |
|
977 |
} |
|
978 |
} |
|
979 |
} |
|
980 |
||
981 |
void CT_FsData::DoCmdEntryL(const TDesC& aSection) |
|
982 |
{ |
|
983 |
TBool isEntryNew = EFalse; |
|
984 |
||
985 |
// Reads the name of file or directory from ini file. |
|
986 |
TPtrC name; |
|
987 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
988 |
{ |
|
989 |
TEntry *entry = NULL; |
|
990 |
||
991 |
// Gets the entry details for a file or directory. |
|
992 |
TPtrC entryObjectName; |
|
993 |
if( GET_OPTIONAL_STRING_PARAMETER( KObjectEntry, aSection, entryObjectName ) ) |
|
994 |
{ |
|
995 |
INFO_PRINTF1( _L( "Get TEntry class instance." ) ); |
|
996 |
TRAPD( err, entry = (TEntry*)GetDataObjectL(entryObjectName)); |
|
997 |
if ( err != KErrNone ) |
|
998 |
{ |
|
999 |
ERR_PRINTF3( _L( "Unrecognized object name parameter value: %S. Error %d"), &entryObjectName, err ); |
|
1000 |
SetBlockResult(EFail); |
|
1001 |
} |
|
1002 |
else |
|
1003 |
{ |
|
1004 |
INFO_PRINTF1( _L( "TEntry class instance accepted OK." ) ); |
|
1005 |
} |
|
1006 |
} |
|
1007 |
else |
|
1008 |
{ |
|
1009 |
INFO_PRINTF1( _L( "Create new temporary TEntry() class instance." ) ); |
|
1010 |
TRAPD( err, entry = new (ELeave) TEntry() ); |
|
1011 |
if ( err!=KErrNone ) |
|
1012 |
{ |
|
1013 |
ERR_PRINTF2( _L( "new TEntry() error %d" ), err ); |
|
1014 |
SetBlockResult(EFail); |
|
1015 |
} |
|
1016 |
else |
|
1017 |
{ |
|
1018 |
isEntryNew = ETrue; |
|
1019 |
} |
|
1020 |
} |
|
1021 |
||
1022 |
if ( entry != NULL ) |
|
1023 |
{ |
|
1024 |
TInt err = iFs->Entry(name, *entry); |
|
1025 |
if (err != KErrNone) |
|
1026 |
{ |
|
1027 |
ERR_PRINTF2(_L("Entry error %d"), err); |
|
1028 |
SetError(err); |
|
1029 |
} |
|
1030 |
else |
|
1031 |
{ |
|
1032 |
// Prints all entry details for the file or directory. |
|
1033 |
// and compares these entry fith entry in ini file |
|
1034 |
TPtrC arrNames[] = |
|
1035 |
{ |
|
1036 |
KEntryAttDirStr(), |
|
1037 |
KEntryAttArchiveStr(), |
|
1038 |
KEntryAttHiddenStr(), |
|
1039 |
KEntryAttReadOnlyStr(), |
|
1040 |
KEntryAttSystemStr(), |
|
1041 |
KEntryAttAllowUidStr() |
|
1042 |
};//size 6 |
|
1043 |
||
1044 |
TInt64 arrFunctions[] = |
|
1045 |
{ |
|
1046 |
entry->IsDir() > 0, |
|
1047 |
entry->IsArchive() > 0, |
|
1048 |
entry->IsHidden() > 0, |
|
1049 |
entry->IsReadOnly() > 0, |
|
1050 |
entry->IsSystem() > 0, |
|
1051 |
entry->IsTypeValid() > 0 |
|
1052 |
};//size 6 |
|
1053 |
||
1054 |
TPtrC iniParam[] = |
|
1055 |
{ |
|
1056 |
KIsAttDir(), |
|
1057 |
KIsAttArchive(), |
|
1058 |
KIsAttHidden(), |
|
1059 |
KIsAttReadOnly(), |
|
1060 |
KIsAttSystem(), |
|
1061 |
KIsAttAllowUid(), |
|
1062 |
};//size 6 |
|
1063 |
||
1064 |
TInt size = sizeof(arrNames) / sizeof(TPtrC); |
|
1065 |
for (TInt i = 0; i < size; i++) |
|
1066 |
{ |
|
1067 |
TBuf<KMaxTestExecuteCommandLength> tempStore; |
|
1068 |
if (arrFunctions[i]) |
|
1069 |
{ |
|
1070 |
tempStore.Format(_L("%S - attribute %S is SET"), &name, &arrNames[i]); |
|
1071 |
} |
|
1072 |
else |
|
1073 |
{ |
|
1074 |
tempStore.Format(_L("%S - attribute %S is NOT SET"), &name, &arrNames[i]); |
|
1075 |
} |
|
1076 |
INFO_PRINTF1(tempStore); |
|
1077 |
||
1078 |
// If iniParam[] is set in ini then compare with attribute returned from function. |
|
1079 |
TBool iniCompare = FALSE; |
|
1080 |
if (GET_OPTIONAL_BOOL_PARAMETER(iniParam[i], aSection, iniCompare)) |
|
1081 |
{ |
|
1082 |
// Compares entry in ini file and entry returned from function. |
|
1083 |
if (arrFunctions[i] != iniCompare) |
|
1084 |
{ |
|
1085 |
ERR_PRINTF2(_L("Error compare attribute %S"), &iniParam[i]); |
|
1086 |
SetBlockResult(EFail); |
|
1087 |
} |
|
1088 |
} |
|
1089 |
} |
|
1090 |
||
1091 |
// Prints size of file. |
|
1092 |
INFO_PRINTF3(_L("%S - size %d"), &name, entry->iSize); |
|
1093 |
||
1094 |
// Compare size of file returned from function with size from ini. |
|
1095 |
TInt iniSize = 0; |
|
1096 |
if (GET_OPTIONAL_INT_PARAMETER(KSize(), aSection, iniSize)) |
|
1097 |
{ |
|
1098 |
if (entry->iSize != iniSize) |
|
1099 |
{ |
|
1100 |
ERR_PRINTF3(_L("Size from ini file not equal with size returned from function (%d != %d)"), iniSize, entry->iSize); |
|
1101 |
SetBlockResult(EFail); |
|
1102 |
} |
|
1103 |
} |
|
1104 |
||
1105 |
// Prints the system time of last modification. |
|
1106 |
TBuf<KTimeFormatSize> dateString; |
|
1107 |
entry->iModified.FormatL(dateString, KTimeFormat); |
|
1108 |
INFO_PRINTF3(_L("%S - modified %S"), &name, &dateString); |
|
1109 |
||
1110 |
// Compare time from ini with time returned from function. |
|
1111 |
TPtrC iniTimeStr; |
|
1112 |
if (GET_OPTIONAL_STRING_PARAMETER(KTime(), aSection, iniTimeStr)) |
|
1113 |
{ |
|
1114 |
// Assigns a date and time contained in a descriptor. |
|
1115 |
TTime iniTime; |
|
1116 |
||
1117 |
TInt error = iniTime.Set(iniTimeStr); |
|
1118 |
if(error == KErrNone) |
|
1119 |
{ |
|
1120 |
// Compares size in ini file and size returned from function. |
|
1121 |
if (entry->iModified != iniTime) |
|
1122 |
{ |
|
1123 |
ERR_PRINTF1(_L("Time from ini file not equal with time returned from function.")); |
|
1124 |
SetBlockResult(EFail); |
|
1125 |
} |
|
1126 |
} |
|
1127 |
else |
|
1128 |
{ |
|
1129 |
ERR_PRINTF3(_L("Cannot convert %S to TTime type. Error: %d"), &iniTimeStr, error); |
|
1130 |
SetBlockResult(EFail); |
|
1131 |
} |
|
1132 |
} |
|
1133 |
||
1134 |
// Prints the file's UIDtype. |
|
1135 |
INFO_PRINTF3(_L("%S - UIDtype %d"), &name, entry->MostDerivedUid().iUid); |
|
1136 |
||
1137 |
if (isEntryNew) |
|
1138 |
{ |
|
1139 |
INFO_PRINTF1(_L("Delete temporary TEntry() class instance.")); |
|
1140 |
delete entry; |
|
1141 |
entry = NULL; |
|
1142 |
} |
|
1143 |
} |
|
1144 |
} |
|
1145 |
} |
|
1146 |
} |
|
1147 |
||
1148 |
void CT_FsData::DoCmdSetEntry(const TDesC& aSection) |
|
1149 |
{ |
|
1150 |
TBool dataOk=ETrue; |
|
1151 |
||
1152 |
TUint setAttMask = 0; |
|
1153 |
if (!FileserverUtil::GetAttMask(*this, aSection, KEntrySetAttMask(), setAttMask)) |
|
1154 |
{ |
|
1155 |
dataOk = EFalse; |
|
1156 |
ERR_PRINTF1(_L("Unknown attribute!")); |
|
1157 |
SetBlockResult(EFail); |
|
1158 |
} |
|
1159 |
||
1160 |
// Reads attributes to be clear from ini file. |
|
1161 |
TUint clearAttMask = 0; |
|
1162 |
if (!FileserverUtil::GetAttMask(*this, aSection, KEntryClearAttMask(), clearAttMask)) |
|
1163 |
{ |
|
1164 |
dataOk = EFalse; |
|
1165 |
ERR_PRINTF1(_L("Unknown attribute!")); |
|
1166 |
SetBlockResult(EFail); |
|
1167 |
} |
|
1168 |
// Reads the time from ini file. |
|
1169 |
TTime time(0); |
|
1170 |
TPtrC inputTime; |
|
1171 |
if (GET_OPTIONAL_STRING_PARAMETER(KTime(), aSection, inputTime)) |
|
1172 |
{ |
|
1173 |
// Assigns a date and time contained in a descriptor. |
|
1174 |
TInt err = time.Set(inputTime); |
|
1175 |
if (err != KErrNone) |
|
1176 |
{ |
|
1177 |
ERR_PRINTF2(_L("Time set failed, error %d"), err); |
|
1178 |
SetBlockResult(EFail); |
|
1179 |
} |
|
1180 |
} |
|
1181 |
||
1182 |
// Reads the name of file or directory from ini file. |
|
1183 |
TPtrC name; |
|
1184 |
if (!GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
1185 |
{ |
|
1186 |
dataOk = EFalse; |
|
1187 |
} |
|
1188 |
||
1189 |
if ( dataOk ) |
|
1190 |
{ |
|
1191 |
// Sets both the attributes and the last modified date and time for a file or directory. |
|
1192 |
TInt err = iFs->SetEntry(name, time, setAttMask, clearAttMask); |
|
1193 |
if (err != KErrNone) |
|
1194 |
{ |
|
1195 |
ERR_PRINTF2(_L("SetEntry error %d"), err); |
|
1196 |
SetError(err); |
|
1197 |
} |
|
1198 |
else |
|
1199 |
{ |
|
1200 |
INFO_PRINTF1(_L("SetEntry() is successful.")); |
|
1201 |
} |
|
1202 |
} |
|
1203 |
} |
|
1204 |
||
1205 |
void CT_FsData::DoCmdReadFileSectionL(const TDesC& aSection) |
|
1206 |
{ |
|
1207 |
TBuf<KMaxTestExecuteCommandLength> tempStore; |
|
1208 |
TBool dataOk = ETrue; |
|
1209 |
||
1210 |
||
1211 |
// Reads the offset, in bytes, from the start of the file where reading is to start. |
|
1212 |
TInt offset = 0; |
|
1213 |
if (!GET_MANDATORY_INT_PARAMETER(KOffset(), aSection, offset)) |
|
1214 |
{ |
|
1215 |
dataOk = EFalse; |
|
1216 |
} |
|
1217 |
||
1218 |
// Reads the number of bytes to be read from the file. |
|
1219 |
TInt lengthRead = 0; |
|
1220 |
if (!GET_MANDATORY_INT_PARAMETER(KLengthRead(), aSection, lengthRead)) |
|
1221 |
{ |
|
1222 |
dataOk = EFalse; |
|
1223 |
} |
|
1224 |
||
1225 |
// Reads the number of bytes to be alocated. |
|
1226 |
TInt lengthBuffer = 0; |
|
1227 |
if (!GET_MANDATORY_INT_PARAMETER(KLengthBuffer(), aSection, lengthBuffer)) |
|
1228 |
{ |
|
1229 |
dataOk = EFalse; |
|
1230 |
} |
|
1231 |
||
1232 |
// Reads the name of file from ini file. |
|
1233 |
TPtrC name; |
|
1234 |
if (!GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
1235 |
{ |
|
1236 |
dataOk = EFalse; |
|
1237 |
} |
|
1238 |
||
1239 |
if ( dataOk ) |
|
1240 |
{ |
|
1241 |
// Creates 8-bit heap descriptor. |
|
1242 |
HBufC8* buffer = NULL; |
|
1243 |
TRAPD (err, buffer = HBufC8::NewL(lengthBuffer)); |
|
1244 |
if (err == KErrNone) |
|
1245 |
{ |
|
1246 |
// Pushes descriptor onto the cleanup stack. |
|
1247 |
CleanupStack::PushL(buffer); |
|
1248 |
||
1249 |
// Create memory for 16-bit bufer. |
|
1250 |
HBufC* buffer16 = NULL; |
|
1251 |
TRAP (err, buffer16 = HBufC::NewL(lengthBuffer)); |
|
1252 |
if (err != KErrNone) |
|
1253 |
{ |
|
1254 |
ERR_PRINTF2(_L("The 16-bit heap descriptor cannot be created, err %d"), err); |
|
1255 |
SetBlockResult(EFail); |
|
1256 |
CleanupStack::PopAndDestroy(buffer); |
|
1257 |
} |
|
1258 |
else |
|
1259 |
{ |
|
1260 |
// Pushes descriptor onto the cleanup stack. |
|
1261 |
CleanupStack::PushL(buffer16); |
|
1262 |
||
1263 |
// Reads data from a file without opening it. |
|
1264 |
TPtr8 bufferPtr = buffer->Des(); |
|
1265 |
err = iFs->ReadFileSection(name, offset, bufferPtr, lengthRead); |
|
1266 |
if (err != KErrNone) |
|
1267 |
{ |
|
1268 |
ERR_PRINTF2(_L("ReadFileSection error %d"), err); |
|
1269 |
SetError(err); |
|
1270 |
} |
|
1271 |
else |
|
1272 |
{ |
|
1273 |
// Writes data from a file. |
|
1274 |
tempStore.Format(_L("The data from a file %S, offset =%d, length_buffer =%d, length_read =%d"), &name, offset, lengthBuffer, lengthRead); |
|
1275 |
INFO_PRINTF1(tempStore); |
|
1276 |
// Converts 8-bit to 16-bit. |
|
1277 |
buffer16->Des().Copy(bufferPtr); |
|
1278 |
TPtr16 bufferPtr16 = buffer16->Des(); |
|
1279 |
INFO_PRINTF2(_L("%S"), &bufferPtr16); |
|
1280 |
} |
|
1281 |
||
1282 |
// Clean memory buffer and buffer16 |
|
1283 |
CleanupStack::PopAndDestroy(2, buffer); // buffer, buffer16. |
|
1284 |
} |
|
1285 |
} |
|
1286 |
else |
|
1287 |
{ |
|
1288 |
ERR_PRINTF2(_L("The 8-bit heap descriptor cannot be created, err %d"), err); |
|
1289 |
SetBlockResult(EFail); |
|
1290 |
} |
|
1291 |
} |
|
1292 |
} |
|
1293 |
||
1294 |
void CT_FsData::DoCmdIsFileOpen(const TDesC& aSection) |
|
1295 |
{ |
|
1296 |
// Reads the name of file from ini file. |
|
1297 |
TPtrC file; |
|
1298 |
if (GET_MANDATORY_STRING_PARAMETER(KFile(), aSection, file)) |
|
1299 |
{ |
|
1300 |
// Tests whether a file is open. |
|
1301 |
TBool isOpen; |
|
1302 |
TInt err = iFs->IsFileOpen(file, isOpen); |
|
1303 |
if (err != KErrNone) |
|
1304 |
{ |
|
1305 |
ERR_PRINTF2(_L("IsFileOpen error %d"), err); |
|
1306 |
SetError(err); |
|
1307 |
} |
|
1308 |
else |
|
1309 |
{ |
|
1310 |
if (isOpen) |
|
1311 |
{ |
|
1312 |
INFO_PRINTF2(_L("The File %S is OPEN"), &file); |
|
1313 |
} |
|
1314 |
else |
|
1315 |
{ |
|
1316 |
INFO_PRINTF2(_L("The FILE %S is CLOSED"), &file); |
|
1317 |
} |
|
1318 |
||
1319 |
// Compare parameter from ini |
|
1320 |
TBool iniIsOpen; |
|
1321 |
if (GET_OPTIONAL_BOOL_PARAMETER(KIsOpen(), aSection, iniIsOpen)) |
|
1322 |
{ |
|
1323 |
if (isOpen != iniIsOpen) |
|
1324 |
{ |
|
1325 |
ERR_PRINTF2(_L("Error compare parameter %S"), &KIsOpen); |
|
1326 |
SetBlockResult(EFail); |
|
1327 |
} |
|
1328 |
} |
|
1329 |
} |
|
1330 |
} |
|
1331 |
} |
|
1332 |
||
1333 |
void CT_FsData::DoCmdGetShortName(const TDesC& aSection) |
|
1334 |
{ |
|
1335 |
// Reads the long name of file from ini file. |
|
1336 |
TPtrC longName; |
|
1337 |
if (GET_MANDATORY_STRING_PARAMETER(KLongName(), aSection, longName)) |
|
1338 |
{ |
|
1339 |
// Gets the short filename associated with a VFAT long filename. |
|
1340 |
TBuf<KShortNameSize> shortName; |
|
1341 |
TInt err = iFs->GetShortName(longName, shortName); |
|
1342 |
if (err != KErrNone) |
|
1343 |
{ |
|
1344 |
ERR_PRINTF2(_L("GetShortName error %d"), err); |
|
1345 |
SetError(err); |
|
1346 |
} |
|
1347 |
else |
|
1348 |
{ |
|
1349 |
INFO_PRINTF2(_L("Short name: %S"), &shortName); |
|
1350 |
||
1351 |
// Compares name from ini file and name from function. |
|
1352 |
TPtrC compareName; |
|
1353 |
if (GET_OPTIONAL_STRING_PARAMETER(KShortName(), aSection, compareName)) |
|
1354 |
{ |
|
1355 |
if (shortName.CompareC(compareName, 0, NULL) != 0) |
|
1356 |
{ |
|
1357 |
ERR_PRINTF3(_L("%S != %S"), &shortName, &compareName); |
|
1358 |
SetBlockResult(EFail); |
|
1359 |
} |
|
1360 |
else |
|
1361 |
{ |
|
1362 |
INFO_PRINTF3(_L("%S == %S"), &shortName, &compareName); |
|
1363 |
} |
|
1364 |
} |
|
1365 |
} |
|
1366 |
} |
|
1367 |
} |
|
1368 |
||
1369 |
void CT_FsData::DoCmdGetLongName(const TDesC& aSection) |
|
1370 |
{ |
|
1371 |
// Reads the short name of file from ini file. |
|
1372 |
TPtrC shortName; |
|
1373 |
if (GET_MANDATORY_STRING_PARAMETER(KShortName(), aSection, shortName)) |
|
1374 |
{ |
|
1375 |
// Gets the long filename associated with a short (8.3) filename. |
|
1376 |
TBuf<KLongNameSize> longName; |
|
1377 |
TInt err = iFs->GetLongName(shortName, longName); |
|
1378 |
if (err != KErrNone) |
|
1379 |
{ |
|
1380 |
ERR_PRINTF2(_L("GetLongName error %d"), err); |
|
1381 |
SetError(err); |
|
1382 |
} |
|
1383 |
else |
|
1384 |
{ |
|
1385 |
INFO_PRINTF2(_L("Long name: %S"), &longName); |
|
1386 |
||
1387 |
// Compares name from ini file and name from function. |
|
1388 |
TPtrC compareName; |
|
1389 |
if (GET_OPTIONAL_STRING_PARAMETER(KLongName(), aSection, compareName)) |
|
1390 |
{ |
|
1391 |
if (longName.CompareC(compareName, 0, NULL) != 0) |
|
1392 |
{ |
|
1393 |
ERR_PRINTF3(_L("%S != %S"), &longName, &compareName); |
|
1394 |
SetBlockResult(EFail); |
|
1395 |
} |
|
1396 |
else |
|
1397 |
{ |
|
1398 |
INFO_PRINTF3(_L("%S == %S"), &longName, &compareName); |
|
1399 |
} |
|
1400 |
} |
|
1401 |
} |
|
1402 |
} |
|
1403 |
} |
|
1404 |
||
1405 |
void CT_FsData::DoCmdIsFileInRom(const TDesC& aSection) |
|
1406 |
{ |
|
1407 |
// Reads the name of file from ini file. |
|
1408 |
TPtrC file; |
|
1409 |
if (GET_MANDATORY_STRING_PARAMETER(KFile(), aSection, file)) |
|
1410 |
{ |
|
1411 |
// Gets a pointer to the specified file, if it is in ROM. |
|
1412 |
iIsFileInRom=iFs->IsFileInRom(file); |
|
1413 |
INFO_PRINTF2(_L("Fs->IsFileInRom = 0x%X"), iIsFileInRom); |
|
1414 |
||
1415 |
TBool isInROM = (iIsFileInRom!=NULL); |
|
1416 |
if ( isInROM ) |
|
1417 |
{ |
|
1418 |
INFO_PRINTF2(_L("File %S in ROM"), &file); |
|
1419 |
} |
|
1420 |
else |
|
1421 |
{ |
|
1422 |
INFO_PRINTF2(_L("File %S not in ROM"), &file); |
|
1423 |
} |
|
1424 |
||
1425 |
// Compare parameter from ini |
|
1426 |
TBool iniIsInROM = FALSE; |
|
1427 |
if (GET_OPTIONAL_BOOL_PARAMETER(KIsInRom(), aSection, iniIsInROM)) |
|
1428 |
{ |
|
1429 |
if (isInROM != iniIsInROM) |
|
1430 |
{ |
|
1431 |
ERR_PRINTF1(_L("Expected result does not match actual")); |
|
1432 |
SetBlockResult(EFail); |
|
1433 |
} |
|
1434 |
} |
|
1435 |
} |
|
1436 |
} |
|
1437 |
||
1438 |
void CT_FsData::DoCmdIsValidName(const TDesC& aSection) |
|
1439 |
{ |
|
1440 |
// Reads the name of file from ini file. |
|
1441 |
TPtrC name; |
|
1442 |
if (GET_MANDATORY_STRING_PARAMETER(KName(), aSection, name)) |
|
1443 |
{ |
|
1444 |
TBool isValid = FALSE; |
|
1445 |
TBool isBadChar; |
|
1446 |
if (GET_OPTIONAL_BOOL_PARAMETER(KIsBadChar(), aSection, isBadChar)) |
|
1447 |
{ |
|
1448 |
// Tests whether a filename and path are syntactically correct. |
|
1449 |
// badChar = on return, contains any illegal character within name, |
|
1450 |
// if the path is valid, badChar is blank. |
|
1451 |
||
1452 |
TText badChar; |
|
1453 |
isValid = iFs->IsValidName(name, badChar); |
|
1454 |
INFO_PRINTF2(_L("BadChar: %c"), badChar); |
|
1455 |
||
1456 |
TPtrC iniBadChar; |
|
1457 |
if (GET_OPTIONAL_STRING_PARAMETER(KBadChar(), aSection, iniBadChar)) |
|
1458 |
{ |
|
1459 |
TText expectedBadChar=iniBadChar[0]; |
|
1460 |
if (badChar != expectedBadChar) |
|
1461 |
{ |
|
1462 |
ERR_PRINTF3(_L("Error compare badchar %c != %c"), badChar, expectedBadChar); |
|
1463 |
SetBlockResult(EFail); |
|
1464 |
} |
|
1465 |
else |
|
1466 |
{ |
|
1467 |
INFO_PRINTF3(_L("Badchar's has equal value %c == %c"), badChar, expectedBadChar); |
|
1468 |
} |
|
1469 |
} |
|
1470 |
} |
|
1471 |
else |
|
1472 |
{ |
|
1473 |
// Tests whether a filename and path are syntactically correct. |
|
1474 |
isValid = iFs->IsValidName(name); |
|
1475 |
} |
|
1476 |
||
1477 |
if (isValid) |
|
1478 |
{ |
|
1479 |
INFO_PRINTF2(_L("Name %S is valid"), &name); |
|
1480 |
} |
|
1481 |
else |
|
1482 |
{ |
|
1483 |
INFO_PRINTF2(_L("Name %S is not valid"), &name); |
|
1484 |
} |
|
1485 |
||
1486 |
// Compare parameter from ini |
|
1487 |
TBool iniIsValid; |
|
1488 |
if (GET_OPTIONAL_BOOL_PARAMETER(KIsValid(), aSection, iniIsValid)) |
|
1489 |
{ |
|
1490 |
if (isValid != iniIsValid) |
|
1491 |
{ |
|
1492 |
ERR_PRINTF1(_L("Error compare with ini parameter")); |
|
1493 |
SetBlockResult(EFail); |
|
1494 |
} |
|
1495 |
} |
|
1496 |
} |
|
1497 |
} |
|
1498 |
||
1499 |
void CT_FsData::DoCmdSetSessionToPrivate(const TDesC& aSection) |
|
1500 |
{ |
|
1501 |
// Reads the name of drive from ini file. |
|
1502 |
TDriveNumber driveNumber; |
|
1503 |
if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber)) |
|
1504 |
{ |
|
1505 |
ERR_PRINTF2(_L("Error read parameter %S"), &KDrive()); |
|
1506 |
SetBlockResult(EFail); |
|
1507 |
} |
|
1508 |
else |
|
1509 |
{ |
|
1510 |
// Sets the session path to point to the private path on the specified drive. |
|
1511 |
TInt err = iFs->SetSessionToPrivate(driveNumber); |
|
1512 |
if (err != KErrNone) |
|
1513 |
{ |
|
1514 |
ERR_PRINTF2(_L("SetSessionToPrivate error %d"), err); |
|
1515 |
SetError(err); |
|
1516 |
} |
|
1517 |
else |
|
1518 |
{ |
|
1519 |
INFO_PRINTF1(_L("Function DoCmdSetSessionToPrivate() OK")); |
|
1520 |
} |
|
1521 |
} |
|
1522 |
} |
|
1523 |
||
1524 |
void CT_FsData::DoCmdPrivatePath(const TDesC& aSection) |
|
1525 |
{ |
|
1526 |
// Creates the text defining the private path for a process. |
|
1527 |
TBuf<KMaxTestExecuteCommandLength> privatePath; |
|
1528 |
TInt err = iFs->PrivatePath(privatePath); |
|
1529 |
if (err != KErrNone) |
|
1530 |
{ |
|
1531 |
ERR_PRINTF2(_L("PrivatePath error %d"), err); |
|
1532 |
SetError(err); |
|
1533 |
} |
|
1534 |
else |
|
1535 |
{ |
|
1536 |
INFO_PRINTF2(_L("PrivatePath: %S"), &privatePath); |
|
1537 |
||
1538 |
// Compares path from ini file and path from function. |
|
1539 |
TPtrC comparePath; |
|
1540 |
if (GET_OPTIONAL_STRING_PARAMETER(KComparePath(), aSection, comparePath)) |
|
1541 |
{ |
|
1542 |
if (comparePath.CompareC(privatePath, 0, NULL) != 0) |
|
1543 |
{ |
|
1544 |
ERR_PRINTF3(_L("%S != %S"), &privatePath, &comparePath); |
|
1545 |
SetBlockResult(EFail); |
|
1546 |
} |
|
1547 |
else |
|
1548 |
{ |
|
1549 |
INFO_PRINTF3(_L("%S == %S"), &privatePath, &comparePath); |
|
1550 |
} |
|
1551 |
} |
|
1552 |
} |
|
1553 |
} |
|
1554 |
||
1555 |
void CT_FsData::DoCmdCreatePrivatePath(const TDesC& aSection) |
|
1556 |
{ |
|
1557 |
// Reads the name of drive from ini file. |
|
1558 |
TDriveNumber driveNumber; |
|
1559 |
if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber)) |
|
1560 |
{ |
|
1561 |
ERR_PRINTF2(_L("Error read parameter %S"), &KDrive()); |
|
1562 |
SetBlockResult(EFail); |
|
1563 |
} |
|
1564 |
else |
|
1565 |
{ |
|
1566 |
// Creates the private path for a process on the specified drive. |
|
1567 |
TInt err = iFs->CreatePrivatePath(driveNumber); |
|
1568 |
if (err != KErrNone) |
|
1569 |
{ |
|
1570 |
ERR_PRINTF2(_L("PrivatePath error %d"), err); |
|
1571 |
SetError(err); |
|
1572 |
} |
|
1573 |
else |
|
1574 |
{ |
|
1575 |
INFO_PRINTF1(_L("Function DoCmdCreatePrivatePath() OK")); |
|
1576 |
} |
|
1577 |
} |
|
1578 |
} |
|
1579 |
||
1580 |
TBool CT_FsData::ConvertToSortKey(const TDesC& aSortKeyStr, TUint& aSortKey) |
|
1581 |
{ |
|
1582 |
TBool ret = ETrue; |
|
1583 |
||
1584 |
if (aSortKeyStr == KESortNone) |
|
1585 |
{ |
|
1586 |
aSortKey = ESortNone; |
|
1587 |
} |
|
1588 |
else if (aSortKeyStr == KESortByName) |
|
1589 |
{ |
|
1590 |
aSortKey = ESortByName; |
|
1591 |
} |
|
1592 |
else if (aSortKeyStr == KESortByExt) |
|
1593 |
{ |
|
1594 |
aSortKey = ESortByExt; |
|
1595 |
} |
|
1596 |
else if (aSortKeyStr == KESortBySize) |
|
1597 |
{ |
|
1598 |
aSortKey = ESortBySize; |
|
1599 |
} |
|
1600 |
else if (aSortKeyStr == KESortByDate) |
|
1601 |
{ |
|
1602 |
aSortKey = ESortByDate; |
|
1603 |
} |
|
1604 |
else if (aSortKeyStr == KESortByUid) |
|
1605 |
{ |
|
1606 |
aSortKey = ESortByUid; |
|
1607 |
} |
|
1608 |
else if (aSortKeyStr == KEDirsAnyOrder) |
|
1609 |
{ |
|
1610 |
aSortKey = EDirsAnyOrder; |
|
1611 |
} |
|
1612 |
else if (aSortKeyStr == KEDirsFirst) |
|
1613 |
{ |
|
1614 |
aSortKey = EDirsFirst; |
|
1615 |
} |
|
1616 |
else if (aSortKeyStr == KEDirsLast) |
|
1617 |
{ |
|
1618 |
aSortKey = EDirsLast; |
|
1619 |
} |
|
1620 |
else if (aSortKeyStr == KEAscending) |
|
1621 |
{ |
|
1622 |
aSortKey = EAscending; |
|
1623 |
} |
|
1624 |
else if (aSortKeyStr == KEDescending) |
|
1625 |
{ |
|
1626 |
aSortKey = EDescending; |
|
1627 |
} |
|
1628 |
else if (aSortKeyStr == KEDirDescending) |
|
1629 |
{ |
|
1630 |
aSortKey = EDirDescending; |
|
1631 |
} |
|
1632 |
else if (aSortKeyStr.Match((_L("*|*"))) != KErrNotFound) |
|
1633 |
{ |
|
1634 |
TUint tmpSortKey; |
|
1635 |
||
1636 |
TInt location = aSortKeyStr.Match(_L("*|*")); |
|
1637 |
//Converting Left part of the data |
|
1638 |
TPtrC left = aSortKeyStr.Left(location); |
|
1639 |
if (ConvertToSortKey(left, tmpSortKey)) |
|
1640 |
{ |
|
1641 |
aSortKey = tmpSortKey; |
|
1642 |
} |
|
1643 |
else |
|
1644 |
{ |
|
1645 |
ret = EFalse; |
|
1646 |
} |
|
1647 |
||
1648 |
//Converting right data can be with another "|" |
|
1649 |
TPtrC right = aSortKeyStr.Mid(location + 1); |
|
1650 |
||
1651 |
if (ConvertToSortKey(right, tmpSortKey)) |
|
1652 |
{ |
|
1653 |
aSortKey = aSortKey | tmpSortKey; |
|
1654 |
} |
|
1655 |
else |
|
1656 |
{ |
|
1657 |
ret = EFalse; |
|
1658 |
} |
|
1659 |
} |
|
1660 |
else |
|
1661 |
{ |
|
1662 |
ret = EFalse; |
|
1663 |
} |
|
1664 |
||
1665 |
return ret; |
|
1666 |
} |
|
1667 |
||
1668 |
const TDesC& CT_FsData::ConvertToStrAttMask(TUint aAttMask) |
|
1669 |
{ |
|
1670 |
switch(aAttMask) |
|
1671 |
{ |
|
1672 |
case KEntryAttReadOnly: |
|
1673 |
return KEntryAttReadOnlyStr; |
|
1674 |
case KEntryAttHidden: |
|
1675 |
return KEntryAttHiddenStr; |
|
1676 |
case KEntryAttSystem: |
|
1677 |
return KEntryAttSystemStr; |
|
1678 |
case KEntryAttVolume: |
|
1679 |
return KEntryAttVolumeStr; |
|
1680 |
case KEntryAttDir: |
|
1681 |
return KEntryAttDirStr; |
|
1682 |
case KEntryAttArchive: |
|
1683 |
return KEntryAttArchiveStr; |
|
1684 |
case KEntryAttXIP: |
|
1685 |
return KEntryAttXIPStr; |
|
1686 |
default: |
|
1687 |
break; |
|
1688 |
}; |
|
1689 |
return KEntryAttUnknown; |
|
1690 |
} |