userlibandfileserver/fileserver/sfsrv/cl_fman.cpp
changeset 152 657f875b013e
parent 0 a41df078684a
child 221 39b39e1a406e
child 247 d8d70de2bd36
equal deleted inserted replaced
139:95f71bcdcdb7 152:657f875b013e
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 
    16 #include "cl_std.h"
    16 #include "cl_std.h"
    17 
    17 
    18 #define RETURNIFERROR(a,b,t)  					\
    18 #ifdef OST_TRACE_COMPILER_IN_USE
    19 	{											\
    19 #include "cl_fmanTraces.h"
    20 	if ((a=b)!=KErrNone)						\
    20 #endif
    21 		{										\
    21 
    22 		if(iStatus)								\
       
    23 			User::RequestComplete(iStatus,a);	\
       
    24 		TInt _t = t;							\
       
    25 		if (_t)	{TRACE1(UTF::EBorder, t, MODULEUID, a);}	\
       
    26 		return(a);								\
       
    27 		}										\
       
    28 	}
       
    29 
       
    30 #define RETURNIFERRORD(a,b,t)  		 			\
       
    31 	TInt a; 									\
       
    32 	RETURNIFERROR(a,b,t)
       
    33 
    22 
    34 const TUint KRecurseFlag	=	0x40000000;
    23 const TUint KRecurseFlag	=	0x40000000;
    35 const TUint KScanDownFlag	=	0x20000000;
    24 const TUint KScanDownFlag	=	0x20000000;
    36 const TUint KFManBusyFlag	=	0x10000000;
    25 const TUint KFManBusyFlag	=	0x10000000;
    37 const TUint KOverWriteFlag	=	0x08000000;
    26 const TUint KOverWriteFlag	=	0x08000000;
   526 @param aFs File server session.
   515 @param aFs File server session.
   527 
   516 
   528 @return Newly created CFileMan object.
   517 @return Newly created CFileMan object.
   529 */
   518 */
   530 	{
   519 	{
   531 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManNewL1, MODULEUID, aFs.Handle());
   520 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANNEWL1, "sess %x", aFs.Handle());
   532 
   521 
   533 	CFileMan* fileMan=new(ELeave) CFileMan(aFs);
   522 	CFileMan* fileMan=new(ELeave) CFileMan(aFs);
   534 	CleanupStack::PushL(fileMan);
   523 	CleanupStack::PushL(fileMan);
   535 	fileMan->CFileBase::ConstructL();
   524 	fileMan->CFileBase::ConstructL();
   536 	CleanupStack::Pop();
   525 	CleanupStack::Pop();
   537 
   526 
   538 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManNewL1Return, MODULEUID, fileMan);
   527 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANNEWL1RETURN, "CFileMan* %x", fileMan);
   539 	return fileMan;
   528 	return fileMan;
   540 	}
   529 	}
   541 
   530 
   542 
   531 
   543 
   532 
   550 @param anObserver File management observer.
   539 @param anObserver File management observer.
   551 
   540 
   552 @return Newly created CFileMan object.
   541 @return Newly created CFileMan object.
   553 */
   542 */
   554 	{
   543 	{
   555 	TRACE2(UTF::EBorder, UTraceModuleEfsrv::ECFileManNewL2, MODULEUID, aFs.Handle(), anObserver);
   544 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANNEWL2, "sess %x anObserver %x", (TUint) aFs.Handle(), (TUint) anObserver);
   556 
   545 
   557 	CFileMan* fileMan=new(ELeave) CFileMan(aFs);
   546 	CFileMan* fileMan=new(ELeave) CFileMan(aFs);
   558 	CleanupStack::PushL(fileMan);
   547 	CleanupStack::PushL(fileMan);
   559 	fileMan->CFileBase::ConstructL();
   548 	fileMan->CFileBase::ConstructL();
   560 	CleanupStack::Pop();
   549 	CleanupStack::Pop();
   561 	fileMan->SetObserver(anObserver);
   550 	fileMan->SetObserver(anObserver);
   562 
   551 
   563 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManNewL2Return, MODULEUID, fileMan);
   552 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANNEWL2RETURN, "CFileMan* %x", fileMan);
   564 	return fileMan;
   553 	return fileMan;
   565 	}
   554 	}
   566 
   555 
   567 
   556 
   568 
   557 
   574 	: CFileBase(aFs)
   563 	: CFileBase(aFs)
   575 	{
   564 	{
   576 	}
   565 	}
   577 CFileMan::~CFileMan()
   566 CFileMan::~CFileMan()
   578 	{
   567 	{
   579 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManDestructor, MODULEUID, this);
   568 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANDESTRUCTOR, "this %x", this);
   580 
   569 
   581 	TRACE0(UTF::EBorder, UTraceModuleEfsrv::ECFileManDestructorReturn, MODULEUID);
   570 	OstTrace0(TRACE_BORDER, EFSRV_ECFILEMANDESTRUCTORRETURN, "");
   582 	}
   571 	}
   583 
   572 
   584 
   573 
   585 EXPORT_C CFileMan::TAction CFileMan::CurrentAction()
   574 EXPORT_C CFileMan::TAction CFileMan::CurrentAction()
   586 /**
   575 /**
   587 Gets the action which CFileMan is currently carrying out.
   576 Gets the action which CFileMan is currently carrying out.
   588 
   577 
   589 @return The action which CFileMan is carrying out.
   578 @return The action which CFileMan is carrying out.
   590 */
   579 */
   591 	{
   580 	{
   592 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManCurrentAction, MODULEUID, this);
   581 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCURRENTACTION, "this %x", this);
   593 
   582 
   594 	TAction action = ENone;
   583 	TAction action = ENone;
   595 
   584 
   596 	// Mapping table between internal and external action indicators.
   585 	// Mapping table between internal and external action indicators.
   597 	switch(iAction)
   586 	switch(iAction)
   626 		break;
   615 		break;
   627 	default:
   616 	default:
   628 		Panic(EFManUnknownAction);
   617 		Panic(EFManUnknownAction);
   629 		}
   618 		}
   630 
   619 
   631 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManCurrentActionReturn, MODULEUID, action);
   620 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCURRENTACTIONRETURN, "action %d", action);
   632 	return (action);
   621 	return (action);
   633 	}
   622 	}
   634 
   623 
   635 
   624 
   636 
   625 
   644 
   633 
   645 @param aTrgName The full path and filename of the target file for
   634 @param aTrgName The full path and filename of the target file for
   646                 the current CFileMan operation
   635                 the current CFileMan operation
   647 */
   636 */
   648 	{
   637 	{
   649 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManGetCurrentTarget, MODULEUID, this);
   638 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANGETCURRENTTARGET, "this %x", this);
   650 
   639 
   651 	GetSrcAndTrg(iTmpParse, aTrgName);
   640 	GetSrcAndTrg(iTmpParse, aTrgName);
   652 
   641 
   653 	TRACEMULT1(UTF::EBorder, UTraceModuleEfsrv::ECFileManGetCurrentTargetReturn, MODULEUID, aTrgName);
   642 	OstTrace0(TRACE_BORDER, EFSRV_ECFILEMANGETCURRENTTARGETRETURN, "");
       
   643 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANGETCURRENTTARGET_EFILENAME, "FileName %S", aTrgName.Ptr(), aTrgName.Length()<<1);
   654 	}
   644 	}
   655 
   645 
   656 
   646 
   657 
   647 
   658 
   648 
   665 
   655 
   666 @param aSrcName The full path and filename of the source file for the current
   656 @param aSrcName The full path and filename of the source file for the current
   667                 CFileMan operation.
   657                 CFileMan operation.
   668 */
   658 */
   669 	{
   659 	{
   670 	TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManGetCurrentSource, MODULEUID, this);
   660 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANGETCURRENTSOURCE, "this %x", this);
   671 
   661 
   672     TPtrC fullPath(FullPath());
   662     TPtrC fullPath(FullPath());
   673 	iTmpParse.Set(CurrentEntry().iName, &fullPath, NULL);
   663 	iTmpParse.Set(CurrentEntry().iName, &fullPath, NULL);
   674 	aSrcName = iTmpParse.FullName();
   664 	aSrcName = iTmpParse.FullName();
   675 
   665 
   676 	TRACEMULT1(UTF::EBorder, UTraceModuleEfsrv::ECFileManGetCurrentSourceReturn, MODULEUID, aSrcName);
   666 	OstTrace0(TRACE_BORDER, EFSRV_ECFILEMANGETCURRENTSOURCERETURN, "");
       
   667 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANGETCURRENTSOURCE_EFILENAME, "FileName %S", aSrcName.Ptr(), aSrcName.Length()<<1);
   677 	}
   668 	}
   678 
   669 
   679 void CFileMan::GetSrcAndTrg(TParse& aSrcName,TFileName& aTrgName)
   670 void CFileMan::GetSrcAndTrg(TParse& aSrcName,TFileName& aTrgName)
   680 //
   671 //
   681 // Get the current target for the operation
   672 // Get the current target for the operation
   732 and may be used to support the increment of progress bars.
   723 and may be used to support the increment of progress bars.
   733 
   724 
   734 @return The number of bytes transferred.
   725 @return The number of bytes transferred.
   735 */
   726 */
   736 	{
   727 	{
   737 	TRACE2(UTF::EBorder, UTraceModuleEfsrv::ECFileManBytesTransferredByCopyStep, MODULEUID, this, iBytesTransferred);
   728 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANBYTESTRANSFERREDBYCOPYSTEP, "this %x BytesTransferred %d", (TUint) this, (TUint) iBytesTransferred);
   738 
   729 
   739 	return(iBytesTransferred);
   730 	return(iBytesTransferred);
   740 	}
   731 	}
   741 
   732 
   742 
   733 
   902 					  this process' SID then AllFiles capability is required.
   893 					  this process' SID then AllFiles capability is required.
   903 @capability Dependent If aName is /Resource then Tcb capability is required.
   894 @capability Dependent If aName is /Resource then Tcb capability is required.
   904 
   895 
   905 */
   896 */
   906 	{
   897 	{
   907 	TRACEMULT8(UTF::EBorder, UTraceModuleEfsrv::ECFileManAttribs1, MODULEUID,
   898 	OstTraceExt5(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS1A, "this %x aSetMask %x aClearMask %x aSwitches %d status %x", (TUint) this, (TUint) aSetMask, (TUint) aClearMask, (TUint) aSwitches, (TUint) &aStatus);
   908 		(TUint) this, aName, aSetMask, aClearMask, I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()), aSwitches, (TUint) &aStatus);
   899 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS1B, "aTime %x:%x ", (TUint) I64HIGH(aTime.Int64()), (TUint) I64LOW(aTime.Int64()));
       
   900 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS1A_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
   909 
   901 
   910 	TInt r;
   902 	TInt r;
   911 	if (iSwitches&KFManBusyFlag)
   903 	if (iSwitches&KFManBusyFlag)
   912 		{
   904 		{
   913 		r = KErrInUse;
   905 		r = KErrInUse;
   916 		{
   908 		{
   917 		iStatus=&aStatus;
   909 		iStatus=&aStatus;
   918 		r = Attribs(aName,aSetMask,aClearMask,aTime,aSwitches);
   910 		r = Attribs(aName,aSetMask,aClearMask,aTime,aSwitches);
   919 		}
   911 		}
   920 
   912 
   921 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManAttribs1Return, MODULEUID, r);
   913 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS1RETURN, "r %d", r);
       
   914 
   922 	return r;
   915 	return r;
   923 	}
   916 	}
   924 
   917 
   925 
   918 
   926 
   919 
   972 					  this process' SID then AllFiles capability is required.
   965 					  this process' SID then AllFiles capability is required.
   973 @capability Dependent If aName is /Resource then Tcb capability is required.
   966 @capability Dependent If aName is /Resource then Tcb capability is required.
   974 
   967 
   975 */
   968 */
   976 	{
   969 	{
   977 	TRACEMULT7(UTF::EBorder, UTraceModuleEfsrv::ECFileManAttribs2, MODULEUID,
   970 	OstTraceExt4(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS2A, "this %x aSetMask %x aClearMask %x aSwitches %x", (TUint) this, (TUint) aSetMask, (TUint) aClearMask, (TUint) aSwitches);
   978 		(TUint) this, aName, aSetMask, aClearMask, I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()), aSwitches);
   971 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS2B, "aTime %x:%x ", (TUint) I64HIGH(aTime.Int64()), (TUint) I64LOW(aTime.Int64()));
       
   972 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS2A_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
   979 
   973 
   980 	TInt ret;
   974 	TInt ret;
   981 	if (iSwitches&KFManBusyFlag)
   975 	if (iSwitches&KFManBusyFlag)
   982 		{
   976 		{
   983 		ret = KErrInUse;
   977 		ret = KErrInUse;
   984 		}
   978 		}
   985 	else
   979 	else
   986 		{
   980 		{
   987 		SetFlags(aSwitches&EOverWrite,aSwitches&ERecurse,ETrue,EFalse);
   981 		SetFlags(aSwitches&EOverWrite,aSwitches&ERecurse,ETrue,EFalse);
   988 		RETURNIFERRORD(r,iFs.Parse(aName,iSrcFile),UTraceModuleEfsrv::ECFileManAttribs2Return);
   982 		TInt r;
       
   983 		if ((r = iFs.Parse(aName,iSrcFile)) != KErrNone)
       
   984 			{
       
   985 			if(iStatus)
       
   986 				User::RequestComplete(iStatus,r);
       
   987 			OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS2RETURN1, "r %d", r);
       
   988 			return r;
       
   989 			}
       
   990 
   989 		iSetMask=aSetMask;
   991 		iSetMask=aSetMask;
   990 		iClearMask=aClearMask;
   992 		iClearMask=aClearMask;
   991 		iTime=aTime;
   993 		iTime=aTime;
   992 		iAction = EInternalAttribs;
   994 		iAction = EInternalAttribs;
   993 		iMatchEntry=KEntryAttMaskSupported; // all entries
   995 		iMatchEntry=KEntryAttMaskSupported; // all entries
   995 		TRAP(r,RunL());
   997 		TRAP(r,RunL());
   996 		ret=(r==KErrNone) ? iLastError : r;
   998 		ret=(r==KErrNone) ? iLastError : r;
   997 		DoSynchronize(r);
   999 		DoSynchronize(r);
   998 		}
  1000 		}
   999 
  1001 
  1000 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManAttribs2Return, MODULEUID, ret);
  1002 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANATTRIBS2RETURN2, "r %d", ret);
       
  1003 
  1001 	return(ret);
  1004 	return(ret);
  1002 	}
  1005 	}
  1003 
  1006 
  1004 
  1007 
  1005 
  1008 
  1035 @capability Dependent If the path for aNew begins with /Sys then Tcb capability is required.
  1038 @capability Dependent If the path for aNew begins with /Sys then Tcb capability is required.
  1036 @capability Dependent If the path for aNew begins with /Resource then Tcb capability is required
  1039 @capability Dependent If the path for aNew begins with /Resource then Tcb capability is required
  1037 
  1040 
  1038 */
  1041 */
  1039 	{
  1042 	{
  1040 	TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy1, MODULEUID,
  1043 	OstTraceExt3(TRACE_BORDER, EFSRV_ECFILEMANCOPY1, "this %x aSwitches %x status %x", (TUint) this, (TUint) aSwitches, (TUint) &aStatus);
  1041 		(TUint) this, anOld, aNew, aSwitches, (TUint) &aStatus);
  1044 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANCOPY1_EOLDNAME, "OldName %S", anOld.Ptr(), anOld.Length()<<1);
       
  1045 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANCOPY1_ENEWNAME, "NewName %S", aNew.Ptr(), aNew.Length()<<1);
  1042 
  1046 
  1043 	TInt r;
  1047 	TInt r;
  1044 	if (iSwitches&KFManBusyFlag)
  1048 	if (iSwitches&KFManBusyFlag)
  1045 		r = KErrInUse;
  1049 		r = KErrInUse;
  1046 	else
  1050 	else
  1047 		{
  1051 		{
  1048 		iStatus=&aStatus;
  1052 		iStatus=&aStatus;
  1049 		r = Copy(anOld,aNew,aSwitches);
  1053 		r = Copy(anOld,aNew,aSwitches);
  1050 		}
  1054 		}
  1051 
  1055 
  1052 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy1Return, MODULEUID, r);
  1056 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY1RETURN, "r %d", r);
       
  1057 
  1053 	return(r);
  1058 	return(r);
  1054 	}
  1059 	}
  1055 
  1060 
  1056 
  1061 
  1057 
  1062 
  1086 using CFileBase::GetLastError().
  1091 using CFileBase::GetLastError().
  1087 
  1092 
  1088 If recursive operation is set, all intermediate directories will be created,
  1093 If recursive operation is set, all intermediate directories will be created,
  1089 including any directories in the path specified by aNew which do not
  1094 including any directories in the path specified by aNew which do not
  1090 already exist.
  1095 already exist.
       
  1096 
       
  1097 If the source (anOld) is a FILE and the recursive operation is set,
       
  1098 then all the files with the same name as anOld in the source directory
       
  1099 including those in subdirectories will be copied to the destination.
       
  1100 
       
  1101 For example, the initial directory structure is as follows:
       
  1102 C:\dir1\file.txt
       
  1103 C:\dir1\subdirA\file.txt
       
  1104 C:\dir1\subdirB\file.txt
       
  1105 
       
  1106 @code
       
  1107 CFileMan* fm(CFileMan::NewL(iFs));	// Where iFs is an RFs handle
       
  1108 fm->Copy(_L("C:\\dir1\\file.txt"), _L("C:\\dir2\\file.txt"), CFileMan::ERecurse);
       
  1109 // OR without specifying the filename in aNew:
       
  1110 fm->Copy(_L("C:\\dir1\\file.txt"), _L("C:\\dir2\\"), CFileMan::ERecurse);
       
  1111 @endcode
       
  1112 
       
  1113 Because of the recursive behaviour, the final directory structure after
       
  1114 either one of the copy operations above will be as follows:
       
  1115 C:\dir1\file.txt
       
  1116 C:\dir1\subdirA\file.txt
       
  1117 C:\dir1\subdirB\file.txt
       
  1118 C:\dir2\file.txt
       
  1119 C:\dir2\subdirA\file.txt
       
  1120 C:\dir2\subdirB\file.txt
  1091 
  1121 
  1092 If recursive operation is not set, only the matching files located in
  1122 If recursive operation is not set, only the matching files located in
  1093 the single directory specified in anOld are copied.
  1123 the single directory specified in anOld are copied.
  1094 No intermediate directories will be created; if any directories in
  1124 No intermediate directories will be created; if any directories in
  1095 the destination path do not exist, no files will be copied, and this function
  1125 the destination path do not exist, no files will be copied, and this function
  1120  	@endcode
  1150  	@endcode
  1121 
  1151 
  1122  1.2	If there is no file to operate on i.e. if source directory is empty, the
  1152  1.2	If there is no file to operate on i.e. if source directory is empty, the
  1123  	function will do nothing and return error code KErrNotFound.
  1153  	function will do nothing and return error code KErrNotFound.
  1124 
  1154 
  1125  2. Files can be copied across drives.
  1155  2.	Files can be copied across drives.
  1126 
  1156 
  1127  3. Open files can be copied if they have been opened using
  1157  3.	Open files can be copied if they have been opened using
  1128       the EFileShareReadersOnly file share mode.
  1158 	the EFileShareReadersOnly file share mode.
  1129 
  1159 
  1130  4. Read-only, hidden and system files can be copied and
  1160  4.	Read-only, hidden and system files can be copied and
  1131    the source file's attributes are preserved in the target file.
  1161 	the source file's attributes are preserved in the target file.
  1132 
  1162 
  1133 @param anOld     Path indicating the file(s) to be copied.
  1163 @param anOld     Path indicating the file(s) to be copied.
  1134                  Any path components which are not specified here will be
  1164                  Any path components which are not specified here will be
  1135                  taken from the session path.
  1165                  taken from the session path.
  1136 @param aNew      Path indicating the directory into which the file(s) are to be copied.
  1166 @param aNew      Path indicating the directory into which the file(s) are to be copied.
  1151 @capability Dependent If the path for anOld begins with /Sys then Tcb capability is required.
  1181 @capability Dependent If the path for anOld begins with /Sys then Tcb capability is required.
  1152 @capability Dependent If the path for anOld begins with /Resource then Tcb capability is required
  1182 @capability Dependent If the path for anOld begins with /Resource then Tcb capability is required
  1153 
  1183 
  1154 */
  1184 */
  1155 	{
  1185 	{
  1156 	TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy2, MODULEUID, (TUint) this, anOld, aNew, aSwitches);
  1186 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANCOPY2, "this %x aSwitches %d", (TUint) this, (TUint) aSwitches);
       
  1187 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANCOPY2_EOLDNAME, "OldName %S", anOld.Ptr(), anOld.Length()<<1);
       
  1188 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANCOPY2_ENEWNAME, "NewName %S", aNew.Ptr(), aNew.Length()<<1);
  1157 
  1189 
  1158 	if (iSwitches&KFManBusyFlag)
  1190 	if (iSwitches&KFManBusyFlag)
  1159 		{
  1191 		{
  1160 		TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy2Return, MODULEUID, KErrInUse);
  1192 		OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY2RETURN1, "r %d", KErrInUse);
  1161 		return(KErrInUse);
  1193 		return(KErrInUse);
  1162 		}
  1194 		}
  1163 	SetFlags(aSwitches&EOverWrite,aSwitches&ERecurse,ETrue,EFalse);
  1195 	SetFlags(aSwitches&EOverWrite,aSwitches&ERecurse,ETrue,EFalse);
  1164 	RETURNIFERRORD(r,iFs.Parse(anOld,iSrcFile),UTraceModuleEfsrv::ECFileManCopy2Return);
  1196 	TInt r;
  1165 	RETURNIFERROR(r,iFs.Parse(aNew,_L("*"),iTrgFile),UTraceModuleEfsrv::ECFileManCopy2Return);
  1197 	if ((r = iFs.Parse(anOld,iSrcFile)) != KErrNone)
       
  1198 		{
       
  1199 		if(iStatus)
       
  1200 			User::RequestComplete(iStatus,r);
       
  1201 		OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY2RETURN2, "r %d", r);
       
  1202 		return r;
       
  1203 		}
       
  1204 
       
  1205 	if ((r = iFs.Parse(aNew,_L("*"),iTrgFile)) != KErrNone)
       
  1206 		{
       
  1207 		if(iStatus)
       
  1208 			User::RequestComplete(iStatus,r);
       
  1209 		OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY2RETURN3, "r %d", r);
       
  1210 		return r;
       
  1211 		}
       
  1212 
  1166 	CheckForDirectory();
  1213 	CheckForDirectory();
  1167 
  1214 
  1168 	if((iSwitches&KRecurseFlag) && iTrgFile.DriveAndPath().MatchF(iSrcFile.FullName()) != KErrNotFound)
  1215 	if((iSwitches&KRecurseFlag) && iTrgFile.DriveAndPath().MatchF(iSrcFile.FullName()) != KErrNotFound)
  1169 		{
  1216 		{
  1170 		TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy2Return, MODULEUID, KErrArgument);
  1217 		OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY2RETURN4, "r %d", KErrArgument);
  1171 		return(KErrArgument);
  1218 		return(KErrArgument);
  1172 		}
  1219 		}
  1173 
  1220 
  1174 	iAction = EInternalCopy;
  1221 	iAction = EInternalCopy;
  1175 	iMatchEntry=KEntryAttMaskSupported;
  1222 	iMatchEntry=KEntryAttMaskSupported;
  1176 	iNumberOfFilesProcessed = 0;
  1223 	iNumberOfFilesProcessed = 0;
  1177 	TRAP(r,RunL());
  1224 	TRAP(r,RunL());
  1178 	TInt ret=(r==KErrNone) ? iLastError : r;
  1225 	TInt ret=(r==KErrNone) ? iLastError : r;
  1179 	DoSynchronize(r);
  1226 	DoSynchronize(r);
  1180 
  1227 
  1181 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy2Return, MODULEUID, ret);
  1228 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY2RETURN5, "r %d", ret);
       
  1229 
  1182 	return(ret);
  1230 	return(ret);
  1183 	}
  1231 	}
  1184 
  1232 
  1185 
  1233 
  1186 
  1234 
  1216 @capability Dependent If aName is /Resource then Tcb capability is required.
  1264 @capability Dependent If aName is /Resource then Tcb capability is required.
  1217 
  1265 
  1218 @see KNullDesC
  1266 @see KNullDesC
  1219 */
  1267 */
  1220 	{
  1268 	{
  1221 	TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::ECFileManDelete1, MODULEUID, (TUint) this, aName, aSwitches, (TUint) &aStatus);
  1269 	OstTraceExt3(TRACE_BORDER, EFSRV_ECFILEMANDELETE1, "this %x aSwitches %x status %x", (TUint) this, (TUint) aSwitches, (TUint) &aStatus);
       
  1270 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANDELETE1_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
  1222 
  1271 
  1223 	TInt r;
  1272 	TInt r;
  1224 	if (iSwitches&KFManBusyFlag)
  1273 	if (iSwitches&KFManBusyFlag)
  1225 		{
  1274 		{
  1226 		r = KErrInUse;
  1275 		r = KErrInUse;
  1229 		{
  1278 		{
  1230 		iStatus=&aStatus;
  1279 		iStatus=&aStatus;
  1231 		r = Delete(aName,aSwitches);
  1280 		r = Delete(aName,aSwitches);
  1232 		}
  1281 		}
  1233 
  1282 
  1234 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManDelete1Return, MODULEUID, r);
  1283 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANDELETE1RETURN, "r %d", r);
       
  1284 
  1235 	return(r);
  1285 	return(r);
  1236 	}
  1286 	}
  1237 
  1287 
  1238 
  1288 
  1239 
  1289 
  1276 @capability Dependent If aName is /Resource then Tcb capability is required.
  1326 @capability Dependent If aName is /Resource then Tcb capability is required.
  1277 
  1327 
  1278 @see KNullDesC
  1328 @see KNullDesC
  1279 */
  1329 */
  1280 	{
  1330 	{
  1281 	TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::ECFileManDelete2, MODULEUID, (TUint) this, aName, aSwitches);
  1331 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANDELETE2, "this %x aSwitches %d", (TUint) this, (TUint) aSwitches);
       
  1332 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANDELETE2_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
  1282 
  1333 
  1283 	TInt ret;
  1334 	TInt ret;
  1284 	if (iSwitches&KFManBusyFlag)
  1335 	if (iSwitches&KFManBusyFlag)
  1285 		{
  1336 		{
  1286 		ret = KErrInUse;
  1337 		ret = KErrInUse;
  1287 		}
  1338 		}
  1288 	else
  1339 	else
  1289 		{
  1340 		{
  1290 		SetFlags(aSwitches&EOverWrite,aSwitches&ERecurse,ETrue,EFalse);
  1341 		SetFlags(aSwitches&EOverWrite,aSwitches&ERecurse,ETrue,EFalse);
  1291 		RETURNIFERRORD(r,iFs.Parse(aName,iSrcFile),UTraceModuleEfsrv::ECFileManDelete2Return);
  1342 		TInt r;
       
  1343 		if ((r = iFs.Parse(aName,iSrcFile)) != KErrNone)
       
  1344 			{
       
  1345 			if(iStatus)
       
  1346 				User::RequestComplete(iStatus,r);
       
  1347 			OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANDELETE2RETURN1, "() r %d", r);
       
  1348 			return r;
       
  1349 			}
       
  1350 
  1292 		iAction = EInternalDelete;
  1351 		iAction = EInternalDelete;
  1293 		iMatchEntry=KEntryAttHidden|KEntryAttMatchExclude|KEntryAttDir;
  1352 		iMatchEntry=KEntryAttHidden|KEntryAttMatchExclude|KEntryAttDir;
  1294 	//	Exclude directories and system files - include hidden files
  1353 	//	Exclude directories and system files - include hidden files
  1295 		iNumberOfFilesProcessed = 0;
  1354 		iNumberOfFilesProcessed = 0;
  1296 		TRAP(r,RunL());
  1355 		TRAP(r,RunL());
  1297 		ret=(r==KErrNone) ? iLastError : r;
  1356 		ret=(r==KErrNone) ? iLastError : r;
  1298 		DoSynchronize(r);
  1357 		DoSynchronize(r);
  1299 		}
  1358 		}
  1300 
  1359 
  1301 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManDelete2Return, MODULEUID, ret);
  1360 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANDELETE2RETURN2, "() r %d", ret);
       
  1361 
  1302 	return(ret);
  1362 	return(ret);
  1303 	}
  1363 	}
  1304 
  1364 
  1305 
  1365 
  1306 
  1366 
  1340 @capability Dependent If the path in anOld starts with /Sys then Tcb capability is required.
  1400 @capability Dependent If the path in anOld starts with /Sys then Tcb capability is required.
  1341 @capability Dependent If the path in anOld starts with /Resource then Tcb capability is required.
  1401 @capability Dependent If the path in anOld starts with /Resource then Tcb capability is required.
  1342 
  1402 
  1343 */
  1403 */
  1344 	{
  1404 	{
  1345 	TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::ECFileManMove1, MODULEUID,
  1405 	OstTraceExt3(TRACE_BORDER, EFSRV_ECFILEMANMOVE1, "this %x aSwitches %x status %x", (TUint) this, (TUint) aSwitches, (TUint) &aStatus);
  1346 		(TUint) this, anOld, aNew, aSwitches, (TUint) &aStatus);
  1406 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANMOVE1_EOLDNAME, "OldName %S", anOld.Ptr(), anOld.Length()<<1);
       
  1407 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANMOVE1_ENEWNAME, "NewName %S", aNew.Ptr(), aNew.Length()<<1);
  1347 
  1408 
  1348 	TInt r;
  1409 	TInt r;
  1349 	if (iSwitches&KFManBusyFlag)
  1410 	if (iSwitches&KFManBusyFlag)
  1350 		{
  1411 		{
  1351 		r = KErrInUse;
  1412 		r = KErrInUse;
  1354 		{
  1415 		{
  1355 		iStatus=&aStatus;
  1416 		iStatus=&aStatus;
  1356 		r = Move(anOld,aNew,aSwitches);
  1417 		r = Move(anOld,aNew,aSwitches);
  1357 		}
  1418 		}
  1358 
  1419 
  1359 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManMove1Return, MODULEUID, r);
  1420 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANMOVE1RETURN, "r %d", r);
       
  1421 
  1360 	return r;
  1422 	return r;
  1361 	}
  1423 	}
  1362 
  1424 
  1363 
  1425 
  1364 
  1426 
  1391   the content of the last directory level only.
  1453   the content of the last directory level only.
  1392 - if there is no trailing backslash ("\") character, then the operation behaves
  1454 - if there is no trailing backslash ("\") character, then the operation behaves
  1393   recursively by default and moves both the last directory level and all of its content.
  1455   recursively by default and moves both the last directory level and all of its content.
  1394   Notice that no trailing backslash ("\") implies moving files recursively automatically.
  1456   Notice that no trailing backslash ("\") implies moving files recursively automatically.
  1395 
  1457 
  1396 For example, if the directory level "b" contains the files F1,F2 and F3, then:
  1458 For example, if the directory level "b" contains the files F1, F2 and F3, then:
  1397 @code
  1459 @code
  1398 CFileMan* fm(CFileMan::NewL(iFs)); // Where iFs is an RFs handle
  1460 CFileMan* fm(CFileMan::NewL(iFs)); // Where iFs is an RFs handle
  1399 ...
  1461 ...
  1400 fm->Move(_L("C:\\a\\b\\"), _L("C:\\x\\y\\"), CFileMan::ERecurse);
  1462 fm->Move(_L("C:\\a\\b\\"), _L("C:\\x\\y\\"), CFileMan::ERecurse);
  1401 @endcode
  1463 @endcode
  1419 
  1481 
  1420 If there is no trailing backslash character and the switch is not set, i.e.
  1482 If there is no trailing backslash character and the switch is not set, i.e.
  1421 0 is passed as an argument, the operation behaves the same way as by passing
  1483 0 is passed as an argument, the operation behaves the same way as by passing
  1422 CFileMan::ERecurse flag.
  1484 CFileMan::ERecurse flag.
  1423 
  1485 
  1424 for example:
  1486 For example:
  1425 @code
  1487 @code
  1426 CFileMan* fm(CFileMan::NewL(iFs)); // Where iFs is an RFs handle
  1488 CFileMan* fm(CFileMan::NewL(iFs)); // Where iFs is an RFs handle
  1427 ...
  1489 ...
  1428 fm->Move(_L("C:\\a\\b"), _L("C:\\x\\y\\"), 0);
  1490 fm->Move(_L("C:\\a\\b"), _L("C:\\x\\y\\"), 0);
  1429 @endcode
  1491 @endcode
  1434 CFileMan* fm(CFileMan::NewL(iFs)); // Where iFs is an RFs handle
  1496 CFileMan* fm(CFileMan::NewL(iFs)); // Where iFs is an RFs handle
  1435 ...
  1497 ...
  1436 fm->Move(_L("C:\\a\\b"), _L("C:\\x\\y\\"), CFileMan::ERecurse);
  1498 fm->Move(_L("C:\\a\\b"), _L("C:\\x\\y\\"), CFileMan::ERecurse);
  1437 @endcode
  1499 @endcode
  1438 
  1500 
       
  1501 If the source (anOld) is a FILE and the recursive operation is set,
       
  1502 then all the files with the same name as anOld in the source directory
       
  1503 including those in subdirectories will be moved to the destination.
       
  1504 
       
  1505 For example, the initial directory structure is as follows:
       
  1506 C:\src\file.txt
       
  1507 C:\src\subdirA\file.txt
       
  1508 C:\src\subdirB\file.txt
       
  1509 
       
  1510 @code
       
  1511 CFileMan* fm(CFileMan::NewL(iFs));	// Where iFs is an RFs handle
       
  1512 fm->Move(_L("C:\\src\\file.txt"), _L("C:\\dest\\file.txt"), CFileMan::ERecurse);
       
  1513 // OR without specifying the filename in aNew:
       
  1514 fm->Move(_L("C:\\src\\file.txt"), _L("C:\\dest\\"), CFileMan::ERecurse);
       
  1515 @endcode
       
  1516 
       
  1517 Because of the recursive behaviour, the final directory structure after
       
  1518 either one of the move operations above will be as follows:
       
  1519 C:\src\
       
  1520 C:\src\subdirA\
       
  1521 C:\src\subdirB\
       
  1522 C:\dest\file.txt
       
  1523 C:\dest\subdirA\file.txt
       
  1524 C:\dest\subdirB\file.txt
       
  1525 
  1439 Notes:
  1526 Notes:
  1440 
  1527 
  1441 -# Read-only, hidden and system files can be moved and the source file's
  1528 -# Read-only, hidden and system files can be moved and the source file's
  1442    attributes are preserved in the target file, but open files cannot
  1529    attributes are preserved in the target file, but open files cannot
  1443    be moved. Attempting to move an open file will return an error for
  1530    be moved. Attempting to move an open file will return an error for
  1444    that file, as retrieved by CFileBase::GetLastError().
  1531    that file, as retrieved by CFileBase::GetLastError().
  1445 
  1532 
  1446 @param anOld	 Path indicating the files to be moved. May be either a full path, or
  1533 @param anOld	 Path indicating the directory/files to be moved. May be either a full path, or
  1447 				 relative to the session path. Note that if you specify a directory level,
  1534 				 relative to the session path. Note that if you specify a directory level,
  1448 				 then the behaviour of the move operation is sensitive to the presence
  1535 				 then the behaviour of the move operation is sensitive to the presence
  1449 				 (or absence) of a trailing backslash ("\") character. Any path components
  1536 				 (or absence) of a trailing backslash ("\") character. Any path components
  1450 				 which are not specified here will be taken from the session path. See the
  1537 				 which are not specified here will be taken from the session path. See the
  1451 				 main description for the detailed explanation.
  1538 				 main description for the detailed explanation.
  1469 @capability Dependent If the path in anOld starts with /Resource then Tcb capability is required.
  1556 @capability Dependent If the path in anOld starts with /Resource then Tcb capability is required.
  1470 
  1557 
  1471 @see CFileBase::GetLastError()
  1558 @see CFileBase::GetLastError()
  1472 */
  1559 */
  1473 	{
  1560 	{
  1474 	TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::ECFileManMove2, MODULEUID,
  1561 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANMOVE2, "this %x aSwitches %d", (TUint) this, (TUint) aSwitches);
  1475 		(TUint) this, anOld, aNew, aSwitches);
  1562 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANMOVE2_EOLDNAME, "OldName %S", anOld.Ptr(), anOld.Length()<<1);
       
  1563 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANMOVE2_ENEWNAME, "NewName %S", aNew.Ptr(), aNew.Length()<<1);
  1476 
  1564 
  1477 
  1565 
  1478 	if (iSwitches&KFManBusyFlag)
  1566 	if (iSwitches&KFManBusyFlag)
  1479 		{
  1567 		{
  1480 		TRACE1(UTF::EBorder, UTraceModuleEfsrv::ECFileManMove2Return, MODULEUID, KErrInUse);
  1568 		OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANMOVE2RETURN1, "r %d", KErrInUse);
  1481 		return(KErrInUse);
  1569 		return(KErrInUse);
  1482 		}
  1570 		}
  1483 
  1571 
  1484 	iNumberOfFilesProcessed = 0;
  1572 	iNumberOfFilesProcessed = 0;
  1485 
  1573 
  1486 	RETURNIFERRORD(r,iFs.Parse(anOld,iSrcFile),UTraceModuleEfsrv::ECFileManMove2Return);
  1574 	TInt r;
  1487 	RETURNIFERROR(r,iFs.Parse(aNew,_L("*"),iTrgFile),UTraceModuleEfsrv::ECFileManMove2Return);
  1575 	if ((r = iFs.Parse(anOld,iSrcFile)) != KErrNone)
       
  1576 		{
       
  1577 		if(iStatus)
       
  1578 			User::RequestComplete(iStatus,r);
       
  1579 		OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANMOVE2RETURN2, "r %d", r);
       
  1580 		return r;
       
  1581 		}
       
  1582 
       
  1583 	if ((r = iFs.Parse(aNew,_L("*"),iTrgFile)) != KErrNone)
       
  1584 		{
       
  1585 		if(iStatus)
       
  1586 			User::RequestComplete(iStatus,r);
       
  1587 		OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANMOVE2RETURN3, "r %d", r);
       
  1588 		return r;
       
  1589 		}
       
  1590 
  1488 
  1591 
  1489 	TInt ret = KErrNone;
  1592 	TInt ret = KErrNone;
  1490 	TBool aComplete = EFalse;
  1593 	TBool aComplete = EFalse;
  1491 	if(SrcTrgDrivesIdentical())
  1594 	if(SrcTrgDrivesIdentical())
  1492 		{
  1595 		{
  1501 		{
  1604 		{
  1502 		if (iStatus)
  1605 		if (iStatus)
  1503 			{
  1606 			{
  1504 			User::RequestComplete(iStatus, ret);
  1607 			User::RequestComplete(iStatus, ret);
  1505 			}
  1608 			}
  1506 		TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManMove2Return, MODULEUID, ret);
  1609 		OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANMOVE2RETURN4, "r %d", ret);
  1507 		return(ret);
  1610 		return(ret);
  1508 		}
  1611 		}
  1509 
  1612 
  1510 	iMatchEntry = KEntryAttMaskSupported;
  1613 	iMatchEntry = KEntryAttMaskSupported;
  1511 	if((aSwitches&ERecurse)==0 && iMovingContents)
  1614 	if((aSwitches&ERecurse)==0 && iMovingContents)
  1516 	// Do the Move or Rename Operation
  1619 	// Do the Move or Rename Operation
  1517 	TRAP(r,RunL());
  1620 	TRAP(r,RunL());
  1518 	ret = (r==KErrNone) ? iLastError : r;
  1621 	ret = (r==KErrNone) ? iLastError : r;
  1519 	DoSynchronize(r);
  1622 	DoSynchronize(r);
  1520 
  1623 
  1521 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManMove2Return, MODULEUID, ret);
  1624 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANMOVE2RETURN5, "r %d", ret);
       
  1625 
  1522 	return(ret);
  1626 	return(ret);
  1523 	}
  1627 	}
  1524 
  1628 
  1525 
  1629 
  1526 TBool CFileMan::SrcTrgDrivesIdentical()
  1630 TBool CFileMan::SrcTrgDrivesIdentical()
  1863 					  this process' SID then AllFiles capability is required.
  1967 					  this process' SID then AllFiles capability is required.
  1864 @capability Dependent If either aName or aNewName is /Resource then Tcb capability is required.
  1968 @capability Dependent If either aName or aNewName is /Resource then Tcb capability is required.
  1865 
  1969 
  1866 */
  1970 */
  1867 	{
  1971 	{
  1868 	TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::ECFileManRename1, MODULEUID,
  1972 	OstTraceExt3(TRACE_BORDER, EFSRV_ECFILEMANRENAME1, "this %x aSwitches %x status %x", (TUint) this, (TUint) aSwitches, (TUint) &aStatus);
  1869 		(TUint) this, aName, aNewName, aSwitches, (TUint) &aStatus);
  1973 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANRENAME1_EOLDNAME, "OldName %S", aName.Ptr(), aName.Length()<<1);
       
  1974 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANRENAME1_ENEWNAME, "NewName %S", aNewName.Ptr(), aNewName.Length()<<1);
  1870 
  1975 
  1871 	TInt r;
  1976 	TInt r;
  1872 	if (iSwitches&KFManBusyFlag)
  1977 	if (iSwitches&KFManBusyFlag)
  1873 		{
  1978 		{
  1874 		r = KErrInUse;
  1979 		r = KErrInUse;
  1877 		{
  1982 		{
  1878 		iStatus=&aStatus;
  1983 		iStatus=&aStatus;
  1879 		r = Rename(aName,aNewName,aSwitches);
  1984 		r = Rename(aName,aNewName,aSwitches);
  1880 		}
  1985 		}
  1881 
  1986 
  1882 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManRename1Return, MODULEUID, r);
  1987 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANRENAME1RETURN, "r %d", r);
       
  1988 
  1883 	return(r);
  1989 	return(r);
  1884 	}
  1990 	}
  1885 
  1991 
  1886 
  1992 
  1887 
  1993 
  2043 					  this process' SID then AllFiles capability is required.
  2149 					  this process' SID then AllFiles capability is required.
  2044 @capability Dependent If either aName or aNewName is /Resource then Tcb capability is required.
  2150 @capability Dependent If either aName or aNewName is /Resource then Tcb capability is required.
  2045 
  2151 
  2046 */
  2152 */
  2047 	{
  2153 	{
  2048 	TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::ECFileManRename2, MODULEUID,
  2154 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANRENAME2, "this %x aSwitches %d", (TUint) this, (TUint) aSwitches);
  2049 		(TUint) this, aName, aNewName, aSwitches);
  2155 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANRENAME2_EOLDNAME, "OldName %S", aName.Ptr(), aName.Length()<<1);
       
  2156 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANRENAME2_ENEWNAME, "NewName %S", aNewName.Ptr(), aNewName.Length()<<1);
  2050 
  2157 
  2051 	TInt ret;
  2158 	TInt ret;
  2052 	if (iSwitches&KFManBusyFlag)
  2159 	if (iSwitches&KFManBusyFlag)
  2053 		{
  2160 		{
  2054 		ret = KErrInUse;
  2161 		ret = KErrInUse;
  2055 		}
  2162 		}
  2056 	else
  2163 	else
  2057 		{
  2164 		{
  2058 		SetFlags(aSwitches&EOverWrite,EFalse,ETrue,EFalse);
  2165 		SetFlags(aSwitches&EOverWrite,EFalse,ETrue,EFalse);
  2059 		RETURNIFERRORD(r,iFs.Parse(aName,iSrcFile),UTraceModuleEfsrv::ECFileManRename2Return);
  2166 		TInt r;
  2060 		RETURNIFERROR(r,iFs.Parse(aNewName,_L("*"),iTrgFile),UTraceModuleEfsrv::ECFileManRename2Return);
  2167 		if ((r = iFs.Parse(aName,iSrcFile)) != KErrNone)
       
  2168 			{
       
  2169 			if(iStatus)
       
  2170 				User::RequestComplete(iStatus,r);
       
  2171 			OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANRENAME2RETURN1, "r %d", r);
       
  2172 			return r;
       
  2173 			}
       
  2174 
       
  2175 		if ((r = iFs.Parse(aNewName,_L("*"),iTrgFile)) != KErrNone)
       
  2176 			{
       
  2177 			if(iStatus)
       
  2178 				User::RequestComplete(iStatus,r);
       
  2179 			OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANRENAME2RETURN2, "r %d", r);
       
  2180 			return r;
       
  2181 			}
  2061 
  2182 
  2062 		iAction = EInternalRename;
  2183 		iAction = EInternalRename;
  2063 		iMatchEntry=KEntryAttMaskSupported;
  2184 		iMatchEntry=KEntryAttMaskSupported;
  2064 		iNumberOfFilesProcessed = 0;
  2185 		iNumberOfFilesProcessed = 0;
  2065 		TRAP(r,RunL());
  2186 		TRAP(r,RunL());
  2066 		ret=(r==KErrNone) ? iLastError : r;
  2187 		ret=(r==KErrNone) ? iLastError : r;
  2067 		DoSynchronize(r);
  2188 		DoSynchronize(r);
  2068 		}
  2189 		}
  2069 
  2190 
  2070 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManRename2Return, MODULEUID, ret);
  2191 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANRENAME2RETURN3, "r %d", ret);
       
  2192 
  2071 	return(ret);
  2193 	return(ret);
  2072 	}
  2194 	}
  2073 
  2195 
  2074 
  2196 
  2075 EXPORT_C TInt CFileMan::RmDir(const TDesC& aDirName,TRequestStatus& aStatus)
  2197 EXPORT_C TInt CFileMan::RmDir(const TDesC& aDirName,TRequestStatus& aStatus)
  2095 					  then AllFiles capability is required.
  2217 					  then AllFiles capability is required.
  2096 @capability Dependent If aDirName starts with /Resource then Tcb capability is required.
  2218 @capability Dependent If aDirName starts with /Resource then Tcb capability is required.
  2097 
  2219 
  2098 */
  2220 */
  2099 	{
  2221 	{
  2100 	TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::ECFileManRmDir1, MODULEUID, (TUint) this, aDirName, (TUint) &aStatus);
  2222 	OstTraceExt2(TRACE_BORDER, EFSRV_ECFILEMANRMDIR1, "this %x status %x", (TUint) this, (TUint) &aStatus);
       
  2223 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANRMDIR1_EDIRNAME, "Dir %S", aDirName.Ptr(), aDirName.Length()<<1);
  2101 
  2224 
  2102 	TInt r;
  2225 	TInt r;
  2103 	if (iSwitches&KFManBusyFlag)
  2226 	if (iSwitches&KFManBusyFlag)
  2104 		{
  2227 		{
  2105 		r = KErrInUse;
  2228 		r = KErrInUse;
  2108 		{
  2231 		{
  2109 		iStatus=&aStatus;
  2232 		iStatus=&aStatus;
  2110 		r = RmDir(aDirName);
  2233 		r = RmDir(aDirName);
  2111 		}
  2234 		}
  2112 
  2235 
  2113 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManRmDir1Return, MODULEUID, r);
  2236 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANRMDIR1RETURN, "r %d", r);
       
  2237 
  2114 	return r;
  2238 	return r;
  2115 	}
  2239 	}
  2116 
  2240 
  2117 
  2241 
  2118 EXPORT_C TInt CFileMan::RmDir(const TDesC& aDirName)
  2242 EXPORT_C TInt CFileMan::RmDir(const TDesC& aDirName)
  2143 @capability Dependent If aDirName starts with /Resource then Tcb capability is required.
  2267 @capability Dependent If aDirName starts with /Resource then Tcb capability is required.
  2144 
  2268 
  2145 
  2269 
  2146 */
  2270 */
  2147 	{
  2271 	{
  2148 	TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::ECFileManRmDir2, MODULEUID, (TUint) this, aDirName);
  2272 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANRMDIR2, "this %x", (TUint) this);
       
  2273 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANRMDIR2_EDIRNAME, "Dir %S", aDirName.Ptr(), aDirName.Length()<<1);
  2149 
  2274 
  2150 	TInt ret;
  2275 	TInt ret;
  2151 	if (iSwitches&KFManBusyFlag)
  2276 	if (iSwitches&KFManBusyFlag)
  2152 		{
  2277 		{
  2153 		ret = KErrInUse;
  2278 		ret = KErrInUse;
  2154 		}
  2279 		}
  2155 	else
  2280 	else
  2156 		{
  2281 		{
  2157 		SetFlags(ETrue,ETrue,EFalse,EFalse);
  2282 		SetFlags(ETrue,ETrue,EFalse,EFalse);
  2158 		RETURNIFERRORD(r,iFs.Parse(aDirName,iTrgFile),UTraceModuleEfsrv::ECFileManRmDir2Return);
  2283 		TInt r;
       
  2284 		if ((r = iFs.Parse(aDirName,iTrgFile)) != KErrNone)
       
  2285 			{
       
  2286 			if(iStatus)
       
  2287 				User::RequestComplete(iStatus,r);
       
  2288 			OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANRMDIR2RETURN1, "r %d", r);
       
  2289 			return r;
       
  2290 			}
       
  2291 
  2159 		iSrcFile.Set(iTrgFile.DriveAndPath(),NULL,NULL);
  2292 		iSrcFile.Set(iTrgFile.DriveAndPath(),NULL,NULL);
  2160 		iAction = EInternalRmDir;
  2293 		iAction = EInternalRmDir;
  2161 		iMatchEntry=KEntryAttMaskSupported;
  2294 		iMatchEntry=KEntryAttMaskSupported;
  2162 		iNumberOfFilesProcessed = 0;
  2295 		iNumberOfFilesProcessed = 0;
  2163 		TRAP(r,RunL());
  2296 		TRAP(r,RunL());
  2164 		DoSynchronize(r);
  2297 		DoSynchronize(r);
  2165 		ret = (r!=KErrNone) ? iLastError : KErrNone;
  2298 		ret = (r!=KErrNone) ? iLastError : KErrNone;
  2166 		}
  2299 		}
  2167 
  2300 
  2168 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManRmDir2Return, MODULEUID, ret);
  2301 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANRMDIR2RETURN2, "r %d", ret);
       
  2302 
  2169 	return ret;
  2303 	return ret;
  2170 	}
  2304 	}
  2171 
  2305 
  2172 
  2306 
  2173 void CFileMan::DoOperationL()
  2307 void CFileMan::DoOperationL()
  2561 @capability Dependent If the path for aNew begins with /Private and does not match
  2695 @capability Dependent If the path for aNew begins with /Private and does not match
  2562 					  this process' SID then AllFiles capability is required.
  2696 					  this process' SID then AllFiles capability is required.
  2563 @capability Dependent If the path for aNew begins with /Resource then Tcb capability is required.
  2697 @capability Dependent If the path for aNew begins with /Resource then Tcb capability is required.
  2564 */
  2698 */
  2565 	{
  2699 	{
  2566 	TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy3, MODULEUID,
  2700 	OstTraceExt3(TRACE_BORDER, EFSRV_ECFILEMANCOPY3, "this %x anOldSubs %x aSwitches %x", (TUint) this, (TUint) anOld.SubSessionHandle(), (TUint) aSwitches);
  2567 		(TUint) this, anOld.SubSessionHandle(), aNew, aSwitches);
  2701 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANCOPY3_ENEWNAME, "NewName %S", aNew.Ptr(), aNew.Length()<<1);
  2568 
  2702 
  2569 	TInt ret;
  2703 	TInt ret;
  2570 	if (iSwitches&KFManBusyFlag)
  2704 	if (iSwitches&KFManBusyFlag)
  2571 		{
  2705 		{
  2572 		ret = KErrInUse;
  2706 		ret = KErrInUse;
  2584 		// need to signal to CFileBase that we're copying from a handle
  2718 		// need to signal to CFileBase that we're copying from a handle
  2585 		// and that iSrcFile is invalid
  2719 		// and that iSrcFile is invalid
  2586 		iSwitches|= KCopyFromHandle;
  2720 		iSwitches|= KCopyFromHandle;
  2587 
  2721 
  2588 		TInt r;
  2722 		TInt r;
  2589 		RETURNIFERROR(r, iFs.Parse(aNew, iTrgFile),UTraceModuleEfsrv::ECFileManCopy3Return);
  2723 		if ((r = iFs.Parse(aNew, iTrgFile)) != KErrNone)
       
  2724 			{
       
  2725 			if(iStatus)
       
  2726 				User::RequestComplete(iStatus,r);
       
  2727 			OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY3RETURN1, "r %d", r);
       
  2728 			return r;
       
  2729 			}
  2590 
  2730 
  2591 		// Need to duplicate the RFile handle so that any threads owned
  2731 		// Need to duplicate the RFile handle so that any threads owned
  2592 		// by this process can use it - i.e. the worker thread
  2732 		// by this process can use it - i.e. the worker thread
  2593 		RETURNIFERROR(r, iSrcFileHandle.Duplicate(anOld, EOwnerProcess),UTraceModuleEfsrv::ECFileManCopy3Return);
  2733 		if ((r = iSrcFileHandle.Duplicate(anOld, EOwnerProcess)) != KErrNone)
       
  2734 			{
       
  2735 			if(iStatus)
       
  2736 				User::RequestComplete(iStatus,r);
       
  2737 			OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY3RETURN2, "r %d", r);
       
  2738 			return r;
       
  2739 			}
  2594 
  2740 
  2595 		iAction = EInternalCopyFromHandle;
  2741 		iAction = EInternalCopyFromHandle;
  2596 		iNumberOfFilesProcessed = 0;
  2742 		iNumberOfFilesProcessed = 0;
  2597 		TRAP(r,RunL());
  2743 		TRAP(r,RunL());
  2598 		ret=(r==KErrNone) ? iLastError : r;
  2744 		ret=(r==KErrNone) ? iLastError : r;
  2599 		DoSynchronize(r);
  2745 		DoSynchronize(r);
  2600 		}
  2746 		}
  2601 
  2747 
  2602 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy3Return, MODULEUID, ret);
  2748 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY3RETURN3, "r %d", ret);
       
  2749 
  2603 	return(ret);
  2750 	return(ret);
  2604 	}
  2751 	}
  2605 
  2752 
  2606 EXPORT_C TInt CFileMan::Copy(const RFile& anOld,const TDesC& aNew,TUint aSwitches,TRequestStatus& aStatus)
  2753 EXPORT_C TInt CFileMan::Copy(const RFile& anOld,const TDesC& aNew,TUint aSwitches,TRequestStatus& aStatus)
  2607 /**
  2754 /**
  2633 @capability Dependent If the path for aNew begins with /Private and does not match
  2780 @capability Dependent If the path for aNew begins with /Private and does not match
  2634 					  this process' SID then AllFiles capability is required.
  2781 					  this process' SID then AllFiles capability is required.
  2635 @capability Dependent If the path for aNew begins with /Resource then Tcb capability is required.
  2782 @capability Dependent If the path for aNew begins with /Resource then Tcb capability is required.
  2636 */
  2783 */
  2637 	{
  2784 	{
  2638 	TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy4, MODULEUID,
  2785 	OstTraceExt4(TRACE_BORDER, EFSRV_ECFILEMANCOPY4, "this %x anOldSubs %x aSwitches %dstatus %x", (TUint) this, (TUint) anOld.SubSessionHandle(), (TUint) aSwitches, (TUint) &aStatus);
  2639 		(TUint) this, anOld.SubSessionHandle(), aNew, aSwitches, (TUint) &aStatus);
  2786 	OstTraceData(TRACE_BORDER, EFSRV_ECFILEMANCOPY4_ENEWNAME, "NewName %S", aNew.Ptr(), aNew.Length()<<1);
  2640 
  2787 
  2641 	TInt r;
  2788 	TInt r;
  2642 	if (iSwitches&KFManBusyFlag)
  2789 	if (iSwitches&KFManBusyFlag)
  2643 		{
  2790 		{
  2644 		r = KErrInUse;
  2791 		r = KErrInUse;
  2647 		{
  2794 		{
  2648 		iStatus=&aStatus;
  2795 		iStatus=&aStatus;
  2649 		r = Copy(anOld,aNew,aSwitches);
  2796 		r = Copy(anOld,aNew,aSwitches);
  2650 		}
  2797 		}
  2651 
  2798 
  2652 	TRACERET1(UTF::EBorder, UTraceModuleEfsrv::ECFileManCopy4Return, MODULEUID, r);
  2799 	OstTrace1(TRACE_BORDER, EFSRV_ECFILEMANCOPY4RETURN, "r %d", r);
       
  2800 
  2653 	return(r);
  2801 	return(r);
  2654 	}
  2802 	}
  2655 
  2803 
  2656 void CFileMan::DoCopyFromHandleL()
  2804 void CFileMan::DoCopyFromHandleL()
  2657 //
  2805 //
  2709 #else
  2857 #else
  2710 TInt CFileMan::DoCopy(const RFile64& aSrcFile, RFile64& aDstFile, TInt& aRet)
  2858 TInt CFileMan::DoCopy(const RFile64& aSrcFile, RFile64& aDstFile, TInt& aRet)
  2711 	{
  2859 	{
  2712 	TInt64 rem;
  2860 	TInt64 rem;
  2713 #endif
  2861 #endif
  2714 	RETURNIFERRORD(r,aSrcFile.Size(rem),EFalse);
  2862 	TInt r;
  2715 	RETURNIFERROR(r, aDstFile.SetSize(rem),EFalse);
  2863 	if ((r = aSrcFile.Size(rem)) != KErrNone)
       
  2864 		{
       
  2865 		if(iStatus)
       
  2866 			User::RequestComplete(iStatus,r);
       
  2867 		return r;
       
  2868 		}
       
  2869 
       
  2870 
       
  2871 	if ((r = aDstFile.SetSize(rem)) != KErrNone)
       
  2872 		{
       
  2873 		if(iStatus)
       
  2874 			User::RequestComplete(iStatus,r);
       
  2875 		return r;
       
  2876 		}
  2716 
  2877 
  2717 	HBufC8* bufPtr = NULL;
  2878 	HBufC8* bufPtr = NULL;
  2718 	bufPtr = AllocateBuffer(rem);
  2879 	bufPtr = AllocateBuffer(rem);
  2719 	if (bufPtr == NULL)
  2880 	if (bufPtr == NULL)
  2720 		return KErrNoMemory;
  2881 		return KErrNoMemory;