51
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 "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: Declaration of the class TATDriveInfo.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "analyzetoolfilelog.h"
|
|
19 |
#include "atdriveinfo.h"
|
|
20 |
#include "atlog.h"
|
|
21 |
#include <analyzetool/customuser.h>
|
|
22 |
#include <analyzetool/analyzetooltraceconstants.h>
|
|
23 |
#include <f32file.h> //RFs
|
|
24 |
#include <utf.h>
|
|
25 |
|
|
26 |
// New file name start and end index.
|
|
27 |
const TInt KNameIndexStart = 1;
|
|
28 |
const TInt KNameIndexEnd = 100;
|
|
29 |
|
|
30 |
RATFileLog::RATFileLog()
|
|
31 |
{
|
|
32 |
|
|
33 |
// Initialize iMicroSecondsAt1970
|
|
34 |
TTime time( KJanuaryFirst1970 );
|
|
35 |
iMicroSecondsAt1970 = time.Int64();
|
|
36 |
iError = KErrNone;
|
|
37 |
}
|
|
38 |
|
|
39 |
RATFileLog::~RATFileLog()
|
|
40 |
{
|
|
41 |
// Auto-generated destructor stub
|
|
42 |
}
|
|
43 |
|
|
44 |
|
|
45 |
// Local time function.
|
|
46 |
TInt64 RATFileLog::CurrentTime()
|
|
47 |
{
|
|
48 |
LOGSTR1( "ATFL void CATStorageServerSession::GetTime()" );
|
|
49 |
|
|
50 |
// Get the current universal time
|
|
51 |
TTime time;
|
|
52 |
time.UniversalTime();
|
|
53 |
|
|
54 |
// Change the time format that tells the number of microseconds from January First,
|
|
55 |
// 0 AD nominal Gregorian, into a format that tells the number of microseconds from
|
|
56 |
// January First, 1970 AD nominal Gregorian. This is a more generic format and
|
|
57 |
// can be directly exploited by the PC code parsing the data file that this
|
|
58 |
// server generates.
|
|
59 |
return ( time.Int64() - iMicroSecondsAt1970 );
|
|
60 |
}
|
|
61 |
|
|
62 |
TInt RATFileLog::ATFileLogVersion()
|
|
63 |
{
|
|
64 |
LOGSTR1( "ATFL CATFileLog::ATFileLogVersion()" );
|
|
65 |
|
52
|
66 |
TInt err( KErrNone );
|
|
67 |
|
51
|
68 |
iFile << KDataFileVersion;
|
|
69 |
|
52
|
70 |
TRAP( err, iFile.CommitL() );
|
|
71 |
return err;
|
51
|
72 |
}
|
|
73 |
|
|
74 |
TInt RATFileLog::ATFileLogProcessStarted( const TDesC8& aProcessName,
|
|
75 |
TUint aProcessId,
|
|
76 |
TUint32 aIsDebug,
|
|
77 |
const TDesC8& aAtoolVersion,
|
|
78 |
const TDesC8& aApiVersion )
|
|
79 |
{
|
|
80 |
LOGSTR1( "ATFL CATFileLog::ATFileLogProcessStarted()" );
|
|
81 |
|
52
|
82 |
TInt err( KErrNone );
|
|
83 |
|
51
|
84 |
// log the current time
|
|
85 |
iFile << this->CurrentTime();
|
|
86 |
|
|
87 |
// <Time stamp> PCS <Process name> <Process ID> <Udeb> <Version>
|
|
88 |
iFile << (TUint8)EProcessStart;
|
|
89 |
iFile << aProcessName;
|
|
90 |
iFile << (TUint32)aProcessId;
|
|
91 |
iFile << aIsDebug;
|
|
92 |
iFile << aAtoolVersion;
|
|
93 |
iFile << aApiVersion;
|
|
94 |
|
|
95 |
// ensure that any buffered data is written to the stream
|
52
|
96 |
TRAP( err, iFile.CommitL() );
|
51
|
97 |
|
52
|
98 |
return err;
|
51
|
99 |
}
|
|
100 |
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
// RATFileLog::ATFileLogProcessEnded
|
|
103 |
//
|
|
104 |
// -----------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
TInt RATFileLog::ATFileLogProcessEnded( TUint aHandleLeakCount )
|
|
107 |
{
|
|
108 |
LOGSTR1( "ATFL CATFileLog::ATFileLogProcessEnded()" );
|
52
|
109 |
|
|
110 |
TInt err( KErrNone );
|
|
111 |
|
51
|
112 |
if ( aHandleLeakCount > 0 )
|
|
113 |
{
|
|
114 |
// HDL <Handle count>
|
|
115 |
iFile << this->CurrentTime();
|
|
116 |
iFile << (TUint8)EHandleLeak;
|
|
117 |
iFile << (TUint32)aHandleLeakCount;
|
|
118 |
}
|
|
119 |
|
|
120 |
// log the current time
|
|
121 |
iFile << this->CurrentTime();
|
|
122 |
|
|
123 |
// PCE
|
|
124 |
iFile << (TUint8)EProcessEnd;
|
|
125 |
|
|
126 |
// ensure that any buffered data is written to the stream
|
52
|
127 |
TRAP( err, iFile.CommitL() );
|
51
|
128 |
|
52
|
129 |
return err;
|
51
|
130 |
}
|
|
131 |
|
|
132 |
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
// RATFileLog::ATFileLogDllLoaded
|
|
135 |
//
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
TInt RATFileLog::ATFileLogDllLoaded( const TDesC8& aDllName, TUint32 aStartAddress,
|
|
139 |
TUint32 aEndAddress )
|
|
140 |
{
|
|
141 |
LOGSTR1( "ATFL CATFileLog::ATFileLogDllLoaded()" );
|
52
|
142 |
|
|
143 |
TInt err( KErrNone );
|
|
144 |
|
51
|
145 |
// log the current time
|
|
146 |
iFile << this->CurrentTime();
|
|
147 |
|
|
148 |
// DLL <DLL name> <Memory start address> <Memory end address>
|
|
149 |
|
|
150 |
// DLL
|
|
151 |
iFile << (TUint8)EDllLoad;
|
|
152 |
// dll name
|
|
153 |
iFile << aDllName;
|
|
154 |
// start adress
|
|
155 |
iFile << aStartAddress;
|
|
156 |
//end adress
|
|
157 |
iFile << aEndAddress;
|
|
158 |
|
|
159 |
// ensure that any buffered data is written to the stream
|
52
|
160 |
TRAP( err, iFile.CommitL() );
|
51
|
161 |
|
52
|
162 |
return err;
|
51
|
163 |
}
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
// -----------------------------------------------------------------------------
|
|
168 |
// RATFileLog::ATFileLogDllUnloaded
|
|
169 |
//
|
|
170 |
// -----------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
TInt RATFileLog::ATFileLogDllUnloaded( const TDesC8& aDllName, TUint32 aStartAddress,
|
|
173 |
TUint32 aEndAddress )
|
|
174 |
{
|
|
175 |
LOGSTR1( "ATFL CATFileLog::ATFileLogDllUnloaded()" );
|
|
176 |
|
52
|
177 |
TInt err( KErrNone );
|
|
178 |
|
51
|
179 |
// log the current time
|
|
180 |
iFile << this->CurrentTime();
|
|
181 |
|
|
182 |
// DLU <DLL name> <Memory start address> <Memory end address>
|
|
183 |
|
|
184 |
// DLU
|
|
185 |
iFile << (TUint8)EDllUnload;
|
|
186 |
// dll name
|
|
187 |
iFile << aDllName;
|
|
188 |
// start adress
|
|
189 |
iFile << aStartAddress;
|
|
190 |
//end adress
|
|
191 |
iFile << aEndAddress;
|
|
192 |
|
|
193 |
// ensure that any buffered data is written to the stream
|
52
|
194 |
TRAP( err, iFile.CommitL() );
|
51
|
195 |
|
52
|
196 |
return err;
|
51
|
197 |
|
|
198 |
}
|
|
199 |
|
|
200 |
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
// RATFileLog::ATFileLogMemoryAllocated
|
|
203 |
//
|
|
204 |
// -----------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
TInt RATFileLog::ATFileLogMemoryAllocated( TUint32 aMemAddress,
|
|
207 |
TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
|
|
208 |
TInt aSize, TUint aThreadId )
|
|
209 |
{
|
|
210 |
LOGSTR1( "ATFL CATFileLog::ATFileLogMemoryAllocated()" );
|
|
211 |
|
52
|
212 |
TInt err( KErrNone );
|
|
213 |
|
51
|
214 |
// ALH <Memory address> <Allocation size> <Thread ID>
|
|
215 |
// <Call stack address count> <Call stack address> <Call stack address> ...
|
|
216 |
|
|
217 |
// log the current time
|
|
218 |
iFile << this->CurrentTime();
|
|
219 |
|
|
220 |
// ALH
|
|
221 |
iFile << (TUint8)EAllocH;
|
|
222 |
// memory adress
|
|
223 |
iFile << aMemAddress;
|
|
224 |
// allocation size
|
|
225 |
iFile << (TUint32)aSize;
|
|
226 |
// thread ID
|
|
227 |
iFile << (TUint32)aThreadId;
|
|
228 |
|
|
229 |
// Search call stack for address count.
|
|
230 |
TInt addrCount(0);
|
|
231 |
for ( TInt j = 0; j < aCallstack.Count() ; j++ )
|
|
232 |
{
|
|
233 |
if ( aCallstack.At(j) == 0 )
|
|
234 |
break;
|
|
235 |
addrCount++;
|
|
236 |
}
|
|
237 |
|
|
238 |
// address count
|
|
239 |
iFile << (TUint32)addrCount;
|
|
240 |
|
|
241 |
// Go through all call stack's memory addresses associated with
|
|
242 |
// this memory allocation
|
|
243 |
for ( TInt addrPos = 0; addrPos < addrCount; addrPos++ )
|
|
244 |
{
|
|
245 |
iFile << aCallstack.At( addrPos );
|
|
246 |
}
|
|
247 |
|
|
248 |
// ensure that any buffered data is written to the stream
|
52
|
249 |
TRAP( err, iFile.CommitL() );
|
51
|
250 |
|
52
|
251 |
return err;
|
51
|
252 |
}
|
|
253 |
|
|
254 |
|
|
255 |
// -----------------------------------------------------------------------------
|
|
256 |
// RATFileLog::ATFileLogMemoryFreed
|
|
257 |
//
|
|
258 |
// -----------------------------------------------------------------------------
|
|
259 |
//
|
|
260 |
TInt RATFileLog::ATFileLogMemoryFreed( TUint32 aMemAddress,
|
|
261 |
TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack,
|
|
262 |
TUint aThreadId )
|
|
263 |
{
|
|
264 |
LOGSTR1( "ATFL CATFileLog::ATFileLogMemoryFreed()" );
|
|
265 |
|
52
|
266 |
TInt err( KErrNone );
|
|
267 |
|
51
|
268 |
// FRH <Memory address> <Thread ID> <Call stack address count>
|
|
269 |
// <Call stack address> <Call stack address> ...
|
|
270 |
|
|
271 |
// log the current time
|
|
272 |
iFile << this->CurrentTime();
|
|
273 |
|
|
274 |
// FRH
|
|
275 |
iFile << (TUint8)EFreeH;
|
|
276 |
|
|
277 |
// Append the start address of this allocation in the 32-bit (max 8 characters)
|
|
278 |
// hexadecimal text format.
|
|
279 |
iFile << aMemAddress;
|
|
280 |
|
|
281 |
// thread ID
|
|
282 |
iFile << (TUint32)aThreadId;
|
|
283 |
|
|
284 |
// Search call stack for address count.
|
|
285 |
TInt addrCount(0);
|
|
286 |
for ( TInt j = 0; j < aFreeCallstack.Count() ; j++ )
|
|
287 |
{
|
|
288 |
if ( aFreeCallstack.At(j) == 0 )
|
|
289 |
break;
|
|
290 |
addrCount++;
|
|
291 |
}
|
|
292 |
|
|
293 |
// address count.
|
|
294 |
iFile << (TUint32)addrCount;
|
|
295 |
|
|
296 |
// Go through all call stack's memory addresses associated with
|
|
297 |
// this memory allocation
|
|
298 |
for ( TInt addrPos = 0; addrPos < addrCount; addrPos++ )
|
|
299 |
{
|
|
300 |
iFile << aFreeCallstack.At( addrPos );
|
|
301 |
}
|
|
302 |
|
|
303 |
// ensure that any buffered data is written to the stream
|
52
|
304 |
TRAP( err, iFile.CommitL() );
|
51
|
305 |
|
52
|
306 |
return err;
|
51
|
307 |
}
|
|
308 |
|
|
309 |
|
|
310 |
// -----------------------------------------------------------------------------
|
|
311 |
// RATFileLog::ATFileLogMemoryReallocated
|
|
312 |
//
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
TInt RATFileLog::ATFileLogMemoryReallocated( TUint32 aMemAddressFree, TUint32 aMemAddressAlloc,
|
|
316 |
TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
|
|
317 |
TInt aSize, TUint aThreadId )
|
|
318 |
{
|
|
319 |
LOGSTR1( "ATFL CATFileLog::ATFileLogMemoryReallocated()" );
|
52
|
320 |
|
|
321 |
TInt err( KErrNone );
|
|
322 |
|
51
|
323 |
// RAH <Freed memory address> <Allocated memory address> <Allocation size> <Thread ID>
|
|
324 |
// <Call stack address count> <Call stack address> <Call stack address> ...
|
|
325 |
|
|
326 |
// log the current time
|
|
327 |
iFile << this->CurrentTime();
|
|
328 |
|
|
329 |
// RAH
|
|
330 |
iFile << (TUint8)EReallocH;
|
|
331 |
// memory adress freed
|
|
332 |
iFile << aMemAddressFree;
|
|
333 |
// memory adress allocated
|
|
334 |
iFile << aMemAddressAlloc;
|
|
335 |
// allocation size
|
|
336 |
iFile << (TUint32)aSize;
|
|
337 |
// thread ID
|
|
338 |
iFile << (TUint32)aThreadId;
|
|
339 |
|
|
340 |
// Search call stack for address count.
|
|
341 |
TInt addrCount(0);
|
|
342 |
for ( TInt j = 0; j < aCallstack.Count() ; j++ )
|
|
343 |
{
|
|
344 |
if ( aCallstack.At(j) == 0 )
|
|
345 |
break;
|
|
346 |
addrCount++;
|
|
347 |
}
|
|
348 |
|
|
349 |
// address count
|
|
350 |
iFile << (TUint32)addrCount;
|
|
351 |
|
|
352 |
// Go through all call stack's memory addresses associated with
|
|
353 |
// this memory allocation
|
|
354 |
for ( TInt addrPos = 0; addrPos < addrCount; addrPos++ )
|
|
355 |
{
|
|
356 |
// Append call stack address.
|
|
357 |
iFile << aCallstack.At( addrPos );
|
|
358 |
}
|
|
359 |
|
|
360 |
// ensure that any buffered data is written to the stream
|
52
|
361 |
TRAP( err, iFile.CommitL() );
|
51
|
362 |
|
52
|
363 |
return err;
|
51
|
364 |
}
|
|
365 |
|
|
366 |
|
|
367 |
// -----------------------------------------------------------------------------
|
|
368 |
// RATFileLog::ATFileLogThreadStarted
|
|
369 |
//
|
|
370 |
// -----------------------------------------------------------------------------
|
|
371 |
//
|
|
372 |
TInt RATFileLog::ATFileLogThreadStarted( TUint aThreadId )
|
|
373 |
{
|
|
374 |
LOGSTR1( "ATFL CATFileLog::ATFileLogThreadStarted()" );
|
|
375 |
|
52
|
376 |
TInt err( KErrNone );
|
|
377 |
|
51
|
378 |
// log the current time
|
|
379 |
iFile << this->CurrentTime();
|
|
380 |
|
|
381 |
// TDS <Thread ID>
|
|
382 |
|
|
383 |
// TDS
|
|
384 |
iFile << (TUint8)EThreadStart;
|
|
385 |
// thread ID
|
|
386 |
iFile << (TUint32)aThreadId;
|
|
387 |
|
|
388 |
// ensure that any buffered data is written to the stream
|
52
|
389 |
TRAP( err, iFile.CommitL() );
|
51
|
390 |
|
52
|
391 |
return err;
|
51
|
392 |
}
|
|
393 |
|
|
394 |
|
|
395 |
// -----------------------------------------------------------------------------
|
|
396 |
// RATFileLog::ATFileLogThreadEnded
|
|
397 |
//
|
|
398 |
// -----------------------------------------------------------------------------
|
|
399 |
//
|
|
400 |
TInt RATFileLog::ATFileLogThreadEnded( TUint64 aThreadId )
|
|
401 |
{
|
52
|
402 |
LOGSTR1( "ATFL CATFileLog::ATFileLogThreadEnded()" );
|
|
403 |
|
|
404 |
TInt err( KErrNone );
|
|
405 |
|
|
406 |
// log the current time
|
|
407 |
iFile << this->CurrentTime();
|
|
408 |
|
|
409 |
// TDE <Thread ID>
|
|
410 |
|
|
411 |
// TDE
|
|
412 |
iFile << (TUint8)EThreadEnd;
|
|
413 |
// thread ID
|
|
414 |
iFile << (TUint32)aThreadId;
|
|
415 |
|
|
416 |
// ensure that any buffered data is written to the stream
|
|
417 |
TRAP( err, iFile.CommitL() );
|
|
418 |
|
|
419 |
return err;
|
51
|
420 |
}
|
|
421 |
|
|
422 |
|
|
423 |
// -----------------------------------------------------------------------------
|
|
424 |
// RATFileLog::ATFileLogDeviceInfo
|
|
425 |
//
|
|
426 |
// -----------------------------------------------------------------------------
|
|
427 |
//
|
|
428 |
TInt RATFileLog::ATFileLogDeviceInfo( const TDesC8& aS60Version, const TDesC8& aChecksum)
|
|
429 |
|
|
430 |
{
|
|
431 |
LOGSTR1( "ATFL CATFileLog::ATFileLogVersionsInfo()" );
|
|
432 |
|
52
|
433 |
TInt err( KErrNone );
|
|
434 |
|
51
|
435 |
// log the current time
|
|
436 |
iFile << this->CurrentTime();
|
|
437 |
|
|
438 |
// VER
|
|
439 |
iFile << (TUint8)EDeviceInfo;
|
|
440 |
// sw version
|
|
441 |
iFile << aS60Version;
|
|
442 |
// rom checksum
|
|
443 |
iFile << aChecksum;
|
|
444 |
|
|
445 |
// ensure that any buffered data is written to the stream
|
52
|
446 |
TRAP( err, iFile.CommitL() );
|
51
|
447 |
|
52
|
448 |
return err;
|
51
|
449 |
}
|
|
450 |
|
|
451 |
|
|
452 |
|
|
453 |
// -----------------------------------------------------------------------------
|
|
454 |
// RATFileLog::OpenFsAndFile
|
|
455 |
// Internally used for opening a handle to the file server and a file
|
|
456 |
// -----------------------------------------------------------------------------
|
|
457 |
//
|
|
458 |
TInt RATFileLog::OpenFsAndFile( const TDesC& aFileName, const TDesC& aFilePath,
|
|
459 |
const TDesC8& aProcessName )
|
|
460 |
{
|
|
461 |
LOGSTR1( "ATFL TInt CATFileLog::OpenFsAndFile()" );
|
|
462 |
|
|
463 |
// Connect file server, return if error occured
|
|
464 |
iError = iFileServer.Connect();
|
|
465 |
if ( iError )
|
|
466 |
{
|
|
467 |
iFileServer.Close();
|
|
468 |
return iError;
|
|
469 |
}
|
|
470 |
|
|
471 |
iError = iFileServer.ShareAuto();
|
|
472 |
if( iError )
|
|
473 |
{
|
|
474 |
iFileServer.Close();
|
|
475 |
return iError;
|
|
476 |
}
|
|
477 |
|
|
478 |
// Open a file
|
|
479 |
TBuf<KMaxFileName> fileNameBuf;
|
|
480 |
|
|
481 |
iError = TATDriveInfo::CreatePath( fileNameBuf, aFileName, aFilePath, iFileServer );
|
|
482 |
|
|
483 |
// Return, if an error occured, and it
|
|
484 |
// is not KErrAlreadyExists
|
|
485 |
if ( iError && iError != KErrAlreadyExists )
|
|
486 |
{
|
|
487 |
iFileServer.Close();
|
|
488 |
return iError;
|
|
489 |
}
|
|
490 |
|
|
491 |
// if file already exist, generat new filename with index
|
|
492 |
GenerateNewFileName( fileNameBuf, aProcessName );
|
|
493 |
|
|
494 |
// Save the file name for this session
|
|
495 |
CnvUtfConverter::ConvertFromUnicodeToUtf8( iLogFile, fileNameBuf );
|
|
496 |
|
|
497 |
LOGSTR2( "ATFL > iError(%i)", iError );
|
|
498 |
|
|
499 |
// If the file does not exist, create it. Write also the version number of
|
|
500 |
// the file at the beginning of the new file
|
|
501 |
if ( iError == KErrNotFound )
|
|
502 |
{
|
|
503 |
iError = iFile.Create( iFileServer, fileNameBuf, EFileWrite | EFileShareAny );
|
|
504 |
if ( !iError )
|
|
505 |
{
|
|
506 |
// todo
|
|
507 |
}
|
|
508 |
}
|
|
509 |
|
|
510 |
if ( iError )
|
|
511 |
{
|
|
512 |
iFile.Close();
|
|
513 |
iFileServer.Close();
|
|
514 |
return iError;
|
|
515 |
}
|
|
516 |
|
|
517 |
return iError;
|
|
518 |
}
|
|
519 |
|
|
520 |
// -----------------------------------------------------------------------------
|
|
521 |
// RATFileLog::GenerateNewFileName
|
|
522 |
// Called internally when need generate new file name.
|
|
523 |
// -----------------------------------------------------------------------------
|
|
524 |
//
|
|
525 |
void RATFileLog::GenerateNewFileName( TDes& aFileName,
|
|
526 |
const TDesC8& aProcessName )
|
|
527 |
{
|
|
528 |
LOGSTR1( "ATFL void CATFileLog::GenerateNewFileName()" );
|
|
529 |
|
|
530 |
// Extension
|
|
531 |
TBuf<KExtensionLength> extension;
|
|
532 |
|
|
533 |
// Check if file already exist
|
|
534 |
CheckIfFileAlreadyExist( aFileName );
|
|
535 |
if ( iError == KErrNotFound )
|
|
536 |
{
|
|
537 |
// If not we can use filename without indexing
|
|
538 |
return;
|
|
539 |
}
|
|
540 |
|
|
541 |
// File with aFileName already exist, let's add index
|
|
542 |
|
|
543 |
// Parse file extension if exists.
|
|
544 |
ParseExtension( aFileName, extension );
|
|
545 |
|
|
546 |
// Temp file name
|
|
547 |
TBuf<KMaxFileName> tempName;
|
|
548 |
|
|
549 |
for ( TInt i = KNameIndexStart; i < KNameIndexEnd; i++ )
|
|
550 |
{
|
|
551 |
tempName.Delete( 0, tempName.MaxLength() );
|
|
552 |
tempName.Format( KFormat, &aFileName, &KLeftBracket, i, &KRightBracket, &extension );
|
|
553 |
LOGSTR2( "ATFL > tempName(%S)", &tempName );
|
|
554 |
// Try to open file
|
|
555 |
CheckIfFileAlreadyExist( tempName );
|
|
556 |
// File does not exist, this index can be used
|
|
557 |
if ( iError == KErrNotFound )
|
|
558 |
{
|
|
559 |
aFileName.Copy( tempName );
|
|
560 |
break;
|
|
561 |
}
|
|
562 |
}
|
|
563 |
}
|
|
564 |
|
|
565 |
// -----------------------------------------------------------------------------
|
|
566 |
// RATFileLog::ParseExtension
|
|
567 |
// Method is used to parse file name extension.
|
|
568 |
// -----------------------------------------------------------------------------
|
|
569 |
//
|
|
570 |
void RATFileLog::ParseExtension(
|
|
571 |
TDes& aFileName, TDes& aExtension )
|
|
572 |
{
|
|
573 |
LOGSTR2( "ATFL void CATFileLog::ParseExtension(%S)",
|
|
574 |
&aFileName );
|
|
575 |
|
|
576 |
// Parse current file name
|
|
577 |
TParse parse;
|
|
578 |
// Set up the TParse object
|
|
579 |
parse.Set( aFileName, NULL, NULL );
|
|
580 |
|
|
581 |
// Tests whether an extension is present.
|
|
582 |
if ( parse.ExtPresent() )
|
|
583 |
{
|
|
584 |
// Gets the extension
|
|
585 |
aExtension.Copy( parse.Ext() );
|
|
586 |
// Remove extension from file name
|
|
587 |
TInt pos( aFileName.Find( aExtension ) );
|
|
588 |
aFileName.Delete( pos, aFileName.Length() );
|
|
589 |
LOGSTR3( "ATFL > aFileName(%S), aExtension(%S)",
|
|
590 |
&aFileName, &aExtension );
|
|
591 |
}
|
|
592 |
}
|
|
593 |
|
|
594 |
// -----------------------------------------------------------------------------
|
|
595 |
// RATFileLog::CheckIfFileAlreadyExist
|
|
596 |
// Method is used to check that file exists and is valid.
|
|
597 |
// -----------------------------------------------------------------------------
|
|
598 |
//
|
|
599 |
void RATFileLog::CheckIfFileAlreadyExist(
|
|
600 |
const TDes& aFileName )
|
|
601 |
{
|
|
602 |
LOGSTR2( "ATFL void CATFileLog::CheckIfFileAlreadyExist(%S)",
|
|
603 |
&aFileName );
|
|
604 |
|
|
605 |
iError = iFile.Open( iFileServer, aFileName, EFileWrite );
|
|
606 |
LOGSTR2( "ATFL > iError(%i)", iError );
|
|
607 |
}
|
|
608 |
|
|
609 |
|
|
610 |
// -----------------------------------------------------------------------------
|
|
611 |
// RATFileLog::CloseFsAndFile
|
|
612 |
// Internally used for closing a handle to the file server and a file
|
|
613 |
// -----------------------------------------------------------------------------
|
|
614 |
//
|
|
615 |
void RATFileLog::CloseFsAndFile()
|
|
616 |
{
|
|
617 |
LOGSTR1( "ATFL void CATFileLog::CloseFsAndFile()" );
|
|
618 |
|
|
619 |
// Close the file
|
|
620 |
iFile.Close();
|
|
621 |
|
|
622 |
// Close the server session and return the error code
|
|
623 |
iFileServer.Close();
|
|
624 |
}
|
|
625 |
|