263 GLDEF_C TInt FManBaseThreadFunction(TAny* aPtr) |
263 GLDEF_C TInt FManBaseThreadFunction(TAny* aPtr) |
264 // |
264 // |
265 // Initialise New thread |
265 // Initialise New thread |
266 // |
266 // |
267 { |
267 { |
268 |
268 TInt r = KErrNoMemory; // return value if a trap harness cannot be created |
269 CTrapCleanup* cleanup=CTrapCleanup::New(); |
269 CTrapCleanup* cleanup=CTrapCleanup::New(); |
270 if (cleanup==NULL) |
|
271 return(KErrNoMemory); |
|
272 CFileBase& fMan=*(CFileBase*)aPtr; |
270 CFileBase& fMan=*(CFileBase*)aPtr; |
273 fMan.iSynchronizer.Wait(); |
271 |
274 TRAPD(ret,DoFManBaseOperationL(aPtr)); |
272 if (cleanup != NULL) |
275 if (ret==KErrNone) |
273 { |
276 ret=fMan.iLastError; |
274 fMan.iSynchronizer.Wait(); |
277 delete cleanup; |
275 TRAP(r,DoFManBaseOperationL(aPtr)); |
|
276 if (r == KErrNone) |
|
277 r = fMan.iLastError; |
|
278 delete cleanup; |
|
279 } |
|
280 |
278 fMan.iSwitches=0; |
281 fMan.iSwitches=0; |
279 fMan.iFs=fMan.iFsOld; |
282 fMan.iFs=fMan.iFsOld; |
280 fMan.iStatus=NULL; |
283 fMan.iStatus=NULL; |
281 fMan.iFManThread.Close(); |
284 fMan.iFManThread.Close(); |
282 return(ret); |
285 return (r); |
283 } |
286 } |
284 |
287 |
285 |
288 |
286 |
289 |
287 |
290 |
290 Creates a separate thread to run the command. |
293 Creates a separate thread to run the command. |
291 |
294 |
292 @param aThreadFunction The thread function. |
295 @param aThreadFunction The thread function. |
293 */ |
296 */ |
294 { |
297 { |
295 iSwitches|=KFManBusyFlag; |
|
296 User::LeaveIfError(iFManThread.Create(KNullDesC,aThreadFunction,KDefaultStackSize,NULL,this)); |
|
297 iFManThread.SetPriority(EPriorityMuchLess); |
|
298 TFileName sessionPath; |
298 TFileName sessionPath; |
299 User::LeaveIfError(iFs.SessionPath(sessionPath)); |
299 User::LeaveIfError(iFs.SessionPath(sessionPath)); |
300 if (iSessionPath==NULL) |
300 if (iSessionPath==NULL) |
301 iSessionPath=HBufC::NewL((sessionPath.Length())); |
301 iSessionPath=HBufC::NewL((sessionPath.Length())); |
302 else if (iSessionPath->Des().MaxLength()<sessionPath.Length()) |
302 else if (iSessionPath->Des().MaxLength()<sessionPath.Length()) |
303 iSessionPath=iSessionPath->ReAllocL(IncPathLength(sessionPath.Length())); |
303 iSessionPath=iSessionPath->ReAllocL(IncPathLength(sessionPath.Length())); |
304 iSessionPath->Des()=sessionPath; |
304 iSessionPath->Des()=sessionPath; |
|
305 |
|
306 User::LeaveIfError(iFManThread.Create(KNullDesC,aThreadFunction,KDefaultStackSize,NULL,this)); |
|
307 |
|
308 // The code won't leave anymore after this. |
|
309 // The effect of any further state changes to this instance |
|
310 // should be undone / completed by the thread function. |
|
311 iFManThread.SetPriority(EPriorityMuchLess); |
|
312 iSwitches|=KFManBusyFlag; |
305 iFsOld=iFs; |
313 iFsOld=iFs; |
306 iLastError=KErrNone; |
314 iLastError=KErrNone; |
307 iFManThread.Logon(*iStatus); |
315 iFManThread.Logon(*iStatus); |
308 iFManThread.Resume(); |
316 iFManThread.Resume(); |
309 } |
317 } |