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