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