userlibandfileserver/fileserver/sfsrv/cl_scan.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 41 0ffb4e86fcc9
child 44 3e88ff8f41d5
equal deleted inserted replaced
42:a179b74831c9 43:c1f20ce4abcf
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 
    16 #include "cl_std.h"
    16 #include "cl_std.h"
    17 #include "cl_scan.h"
    17 #include "cl_scan.h"
       
    18 
       
    19 #ifdef OST_TRACE_COMPILER_IN_USE
       
    20 #include "cl_scanTraces.h"
       
    21 #endif
    18 
    22 
    19 const TInt KDirStackGranularity=8;
    23 const TInt KDirStackGranularity=8;
    20 
    24 
    21 /** Replace long names in path and filename with their sohrter version (if exists). Optionally appends
    25 /** Replace long names in path and filename with their sohrter version (if exists). Optionally appends
    22 filename to path name creating fully qualified file name.
    26 filename to path name creating fully qualified file name.
   113 @param aFs The file server session.
   117 @param aFs The file server session.
   114 
   118 
   115 @return A pointer to the new directory scan object.
   119 @return A pointer to the new directory scan object.
   116 */
   120 */
   117 	{
   121 	{
   118 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanNewLC, MODULEUID, aFs.Handle());
   122 	OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANNEWLC, "sess %x", aFs.Handle());
   119 
   123 
   120 	CDirScan* scan=new(ELeave) CDirScan(aFs);
   124 	CDirScan* scan=new(ELeave) CDirScan(aFs);
   121 	CleanupStack::PushL(scan);
   125 	CleanupStack::PushL(scan);
   122 	scan->iStack=CDirStack::NewL();
   126 	scan->iStack=CDirStack::NewL();
   123 
   127 
   124 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanNewLCReturn, MODULEUID, scan);
   128 	OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANNEWLCRETURN, "CDirScan* %x", scan);
   125 	return scan;
   129 	return scan;
   126 	}
   130 	}
   127 
   131 
   128 
   132 
   129 
   133 
   135 @param aFs The file server session.
   139 @param aFs The file server session.
   136 
   140 
   137 @return A pointer to the new directory scan object.
   141 @return A pointer to the new directory scan object.
   138 */
   142 */
   139 	{
   143 	{
   140 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanNewL, MODULEUID, aFs.Handle());
   144 	OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANNEWL, "sess %x", aFs.Handle());
   141 
   145 
   142 	CDirScan* scan=CDirScan::NewLC(aFs);
   146 	CDirScan* scan=CDirScan::NewLC(aFs);
   143 	CleanupStack::Pop();
   147 	CleanupStack::Pop();
   144 
   148 
   145 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanNewLReturn, MODULEUID, scan);
   149 	OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANNEWLRETURN, "CDirScan* %x", scan);
   146 	return scan;
   150 	return scan;
   147 	}
   151 	}
   148 
   152 
   149 
   153 
   150 
   154 
   154 Desctructor.
   158 Desctructor.
   155 
   159 
   156 Frees all resources owned by the object, prior to its destruction.
   160 Frees all resources owned by the object, prior to its destruction.
   157 */
   161 */
   158 	{
   162 	{
   159 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanDestructor, MODULEUID, this);
   163 	OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANDESTRUCTOR, "this %x", this);
   160 
   164 
   161 	delete iStack;
   165 	delete iStack;
   162 
   166 
   163 	TRACE0(UTF::EBorder, UTraceModuleEfsrv::ECDirScanDestructorReturn, MODULEUID);
   167 	OstTrace0(TRACE_BORDER, EFSRV_ECDIRSCANDESTRUCTORRETURN, "");
   164 	}
   168 	}
   165 
   169 
   166 
   170 
   167 
   171 
   168 
   172 
   212 @param anEntrySortKey The order in which the directories are scanned by
   216 @param anEntrySortKey The order in which the directories are scanned by
   213                       NextL(). This flag is defined in TEntryKey.
   217                       NextL(). This flag is defined in TEntryKey.
   214 @param aScanDir       The direction of the scan. The default is downwards.
   218 @param aScanDir       The direction of the scan. The default is downwards.
   215 */
   219 */
   216 	{
   220 	{
   217 	TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::ECDirScanSetScanDataL, MODULEUID, (TUint) 
   221 	OstTraceExt4(TRACE_BORDER, EFSRV_ECDIRSCANSETSCANDATAL, "this %x anEntryAttMask %x anEntrySortKey %d aScanDir %d", (TUint) this, (TUint) anEntryAttMask, (TUint) anEntrySortKey, (TUint) aScanDir);
   218 		this, aMatchName, anEntryAttMask, anEntrySortKey, (TUint) aScanDir);
   222 	OstTraceData(TRACE_BORDER, EFSRV_ECDIRSCANSETSCANDATAL_EFILEPATH, "FilePath %S", aMatchName.Ptr(), aMatchName.Length()<<1);
   219 
   223 
   220 	TInt r = Fs().Parse(aMatchName,iFullPath);
   224 	TInt r = Fs().Parse(aMatchName,iFullPath);
   221 	if (r != KErrNone)
   225 	if (r != KErrNone)
   222 		{
   226 		{
   223 		TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanSetScanDataLReturn, MODULEUID, r);
   227 		OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANSETSCANDATALRETURN1, "r %d", r);
   224 		User::Leave(r);
   228 		User::Leave(r);
   225 		}
   229 		}
   226 
   230 
   227 	iScanning = ETrue;
   231 	iScanning = ETrue;
   228 	iEntryAttMask=anEntryAttMask;
   232 	iEntryAttMask=anEntryAttMask;
   232 	iAbbreviatedPath.Set(_L("\\"));
   236 	iAbbreviatedPath.Set(_L("\\"));
   233 	iScanDir=aScanDir;
   237 	iScanDir=aScanDir;
   234 	if (aScanDir==EScanDownTree)
   238 	if (aScanDir==EScanDownTree)
   235 		iFullPath.PopDir();
   239 		iFullPath.PopDir();
   236 
   240 
   237 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanSetScanDataLReturn, MODULEUID, KErrNone);
   241 	OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANSETSCANDATALRETURN2, "r %d", KErrNone);
   238 	}
   242 	}
   239 
   243 
   240 void CDirScan::UpdateAbbreviatedPath()
   244 void CDirScan::UpdateAbbreviatedPath()
   241 //
   245 //
   242 // Set the abbreviated path based on the full path
   246 // Set the abbreviated path based on the full path
   276 @param aDirEntries On return, a pointer to an array containing filtered entries
   280 @param aDirEntries On return, a pointer to an array containing filtered entries
   277                    from the next directory in the structure. NULL if there are
   281                    from the next directory in the structure. NULL if there are
   278                    no more directories in the structure.
   282                    no more directories in the structure.
   279 */
   283 */
   280 	{
   284 	{
   281 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanNextL, MODULEUID, this);
   285 	OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANNEXTL, "this %x", this);
   282 
   286 
   283 	if (iScanDir==EScanUpTree)
   287 	if (iScanDir==EScanUpTree)
   284 		ScanUpTreeL(aDirEntries);
   288 		ScanUpTreeL(aDirEntries);
   285 	else
   289 	else
   286 		ScanDownTreeL(aDirEntries);
   290 		ScanDownTreeL(aDirEntries);
   287 
   291 
   288 	TRACE2(UTF::EBorder, UTraceModuleEfsrv::ECDirScanNextLReturn, MODULEUID, 
   292 	OstTraceExt2(TRACE_BORDER, EFSRV_ECDIRSCANNEXTLRETURN, "r %d DirEntries %d", (TUint) KErrNone, (TUint) aDirEntries ? (*aDirEntries).Count() : 0);
   289 		KErrNone, aDirEntries ? (*aDirEntries).Count() : 0);
       
   290 	}
   293 	}
   291 
   294 
   292 void CDirScan::ScanUpTreeL(CDir*& aDirEntries)
   295 void CDirScan::ScanUpTreeL(CDir*& aDirEntries)
   293 //
   296 //
   294 // Get the next directory starting from the bottom of the tree
   297 // Get the next directory starting from the bottom of the tree
   335 					}
   338 					}
   336 				}
   339 				}
   337 			}
   340 			}
   338 		if (r != KErrNone)
   341 		if (r != KErrNone)
   339 			{
   342 			{
   340 			TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanLeave, MODULEUID, r);
   343 			OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANLEAVE1, "r %d", r);
   341 			User::LeaveIfError(r);
   344 			User::LeaveIfError(r);
   342 			}
   345 			}
   343 
   346 
   344 		CDir* dirList;
   347 		CDir* dirList;
   345 		//	Start by searching for directories only	from top to bottom
   348 		//	Start by searching for directories only	from top to bottom
   353 			aDirEntries = CDirFactory::NewL();
   356 			aDirEntries = CDirFactory::NewL();
   354 			}
   357 			}
   355 		else if (r != KErrNone)
   358 		else if (r != KErrNone)
   356 			{
   359 			{
   357 			iScanning = EFalse;
   360 			iScanning = EFalse;
   358 			TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanLeave, MODULEUID, r);
   361 			OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANLEAVE2, "r %d", r);
   359 			User::Leave(r);
   362 			User::Leave(r);
   360 			}
   363 			}
   361 		
   364 		
   362 		iScanning= EFalse;
   365 		iScanning= EFalse;
   363 		
   366 		
   391 //
   394 //
   392 	{
   395 	{
   393 	TInt r = Fs().GetDir(iFullPath.FullName(),iEntryAttMask,iEntrySortMask,aDirEntries);
   396 	TInt r = Fs().GetDir(iFullPath.FullName(),iEntryAttMask,iEntrySortMask,aDirEntries);
   394 	if (r != KErrNone)
   397 	if (r != KErrNone)
   395 		{
   398 		{
   396 		TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanLeave, MODULEUID, r);
   399 		OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANLEAVE3, "r %d", r);
   397 		User::Leave(r);
   400 		User::Leave(r);
   398 		}
   401 		}
   399 	}
   402 	}
   400 
   403 
   401 void CDirScan::ScanDownTreeL(CDir*& aDirEntries)
   404 void CDirScan::ScanDownTreeL(CDir*& aDirEntries)
   405 //
   408 //
   406 	{
   409 	{
   407 	CDir* dirEntries = NULL;
   410 	CDir* dirEntries = NULL;
   408 	TInt r;
   411 	TInt r;
   409 	aDirEntries=NULL;
   412 	aDirEntries=NULL;
   410 		
   413 	
   411 	if(iStack && iStack->IsEmpty())
   414 	if(iStack->IsEmpty())
   412 	    return;
   415 	    return;
   413 	
   416 	
   414 	CDirList* list=iStack->Peek();
   417 	CDirList* list=iStack->Peek();
   415 	while (!list->MoreEntries())
   418 	while (!list->MoreEntries())
   416 		{
   419 		{
   427 
   430 
   428 	TPtrC dirName=list->Next().iName;
   431 	TPtrC dirName=list->Next().iName;
   429 	r=iFullPath.AddDir(dirName);
   432 	r=iFullPath.AddDir(dirName);
   430 	if (r==KErrGeneral)	//	Adding dirName makes iFullPath>256 characters
   433 	if (r==KErrGeneral)	//	Adding dirName makes iFullPath>256 characters
   431 		{
   434 		{
   432 		TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanLeave, MODULEUID, KErrTooBig);
   435 		OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANLEAVE4, "r %d", KErrTooBig);
   433 		User::Leave(KErrTooBig);
   436 		User::Leave(KErrTooBig);
   434 		}
   437 		}
   435 
   438 
   436 	//	Get all valid entries in this directory
   439 	//	Get all valid entries in this directory
   437 	
   440 	
   449 		r = Fs().GetDir(iFullPath.DriveAndPath(),
   452 		r = Fs().GetDir(iFullPath.DriveAndPath(),
   450 									   KEntryAttDir|KEntryAttMatchExclusive|(iEntryAttMask&KEntryAttMatchMask),
   453 									   KEntryAttDir|KEntryAttMatchExclusive|(iEntryAttMask&KEntryAttMatchMask),
   451 									   iEntrySortMask,dirList);
   454 									   iEntrySortMask,dirList);
   452 		if (r != KErrNone)
   455 		if (r != KErrNone)
   453 			{
   456 			{
   454 			TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanLeave, MODULEUID, r);
   457 			OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANLEAVE5, "r %d", r);
   455 			User::Leave(r);
   458 			User::Leave(r);
   456 			}
   459 			}
   457 		iStack->PushL(*dirList);
   460 		iStack->PushL(*dirList);
   458 		CleanupStack::Pop();	// dirEntries
   461 		CleanupStack::Pop();	// dirEntries
   459 		UpdateAbbreviatedPath();
   462 		UpdateAbbreviatedPath();
   466 		aDirEntries = CDirFactory::NewL();
   469 		aDirEntries = CDirFactory::NewL();
   467 		}
   470 		}
   468 	else
   471 	else
   469 		{
   472 		{
   470 		iScanning = EFalse;
   473 		iScanning = EFalse;
   471 		TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanLeave, MODULEUID, r);
   474 		OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANLEAVE6, "r %d", r);
   472 		User::Leave(r);
   475 		User::Leave(r);
   473 		}
   476 		}
   474 	}
   477 	}
   475 
   478 
   476 
   479 
   570 
   573 
   571 	TInt r=iDirStack.Append(nextLevel);
   574 	TInt r=iDirStack.Append(nextLevel);
   572 	if (r!=KErrNone)
   575 	if (r!=KErrNone)
   573 		{
   576 		{
   574 		delete nextLevel;
   577 		delete nextLevel;
   575 		TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanLeave, MODULEUID, r);
   578 		OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANLEAVE7, "r %d", r);
   576 		User::Leave(r);
   579 		User::Leave(r);
   577 		}
   580 		}
   578 	}
   581 	}
   579 
   582 
   580 void CDirStack::Pop()
   583 void CDirStack::Pop()
   708 		{
   711 		{
   709 		TThreadId theId;
   712 		TThreadId theId;
   710 		TInt r = iFs->GetOpenFileList(iScanPos,iEntryListPos,theId,array);
   713 		TInt r = iFs->GetOpenFileList(iScanPos,iEntryListPos,theId,array);
   711 		if (r != KErrNone)
   714 		if (r != KErrNone)
   712 			{
   715 			{
   713 			TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECDirScanLeave, MODULEUID, r);
   716 			OstTrace1(TRACE_BORDER, EFSRV_ECDIRSCANLEAVE8, "r %d", r);
   714 			User::Leave(r);
   717 			User::Leave(r);
   715 			}
   718 			}
   716 		TInt count=array.Count();
   719 		TInt count=array.Count();
   717 		if (count==0)
   720 		if (count==0)
   718 			{
   721 			{