userlibandfileserver/fileserver/sfile/sf_drv.cpp
branchRCL_3
changeset 41 0ffb4e86fcc9
parent 8 538db54a451d
child 42 a179b74831c9
equal deleted inserted replaced
39:2bb754abd467 41:0ffb4e86fcc9
    82 		aRequest->SetDrive(&aRequest->Drive()->SubstedDrive());
    82 		aRequest->SetDrive(&aRequest->Drive()->SubstedDrive());
    83 		}
    83 		}
    84 	return(KErrNone);
    84 	return(KErrNone);
    85 	}
    85 	}
    86 
    86 
    87 void ValidateAtts(TUint /*anEntryAtts*/,TUint& aSetAttMask,TUint& aClearAttMask)
    87 void ValidateAtts(TUint& aSetAttMask,TUint& aClearAttMask)
    88 //
    88 //
    89 // Do not allow the entry type to be changed
    89 // Do not allow the entry type to be changed
    90 //
    90 //
    91 	{
    91 	{
    92 	const TUint KReadOnlySetAtts = KEntryAttVolume | 
    92 	const TUint KReadOnlySetAtts = KEntryAttVolume | 
   231 			}
   231 			}
   232 		}
   232 		}
   233 
   233 
   234 	if (iReason==KErrNone && CurrentMount().LockStatus() > 0)
   234 	if (iReason==KErrNone && CurrentMount().LockStatus() > 0)
   235 	    {
   235 	    {
   236     	//-- this meand that the mount has drive access objetcs opened (RFormat or RRawDisk)
   236     	//-- this means that the mount has drive access objects opened (RFormat or RRawDisk)
   237         __PRINT1(_L("TDrive::CheckMount() Mount is locked! LockStaus:%d"), CurrentMount().LockStatus());
   237         __PRINT1(_L("TDrive::CheckMount() Mount is locked! LockStaus:%d"), CurrentMount().LockStatus());
   238         return KErrInUse;
   238         return KErrInUse;
   239 	    }	
   239 	    }	
   240 
   240 
   241 	__PRINT1(_L("TDrive::CheckMount returned %d "),iReason);
   241 	__PRINT1(_L("TDrive::CheckMount returned %d "),iReason);
  1163 void TDrive::DoEntryL(const TDesC& aName, TEntry& anEntry)
  1163 void TDrive::DoEntryL(const TDesC& aName, TEntry& anEntry)
  1164 //
  1164 //
  1165 // Get entry details
  1165 // Get entry details
  1166 //
  1166 //
  1167 	{
  1167 	{
  1168 	FlushCachedFileInfoL();
       
  1169 
       
  1170 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBEntryL, EF32TraceUidFileSys, DriveNumber(), aName);
  1168 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBEntryL, EF32TraceUidFileSys, DriveNumber(), aName);
  1171 	CurrentMount().EntryL(aName,anEntry);
  1169 	CurrentMount().EntryL(aName,anEntry);
       
  1170 
       
  1171 	// If the file is already open then read the file attributes directly from the file
       
  1172 	TFileName foldedName;
       
  1173 	TUint32 nameHash=0;
       
  1174 	foldedName.CopyF(aName);
       
  1175 	nameHash=CalcNameHash(foldedName);
       
  1176 
       
  1177 	__CHECK_DRIVETHREAD(iDriveNumber);
       
  1178 	TDblQueIter<CFileCB> q(CurrentMount().iMountQ);
       
  1179 	CMountCB* currentMount = &CurrentMount();
       
  1180 	CFileCB* file;
       
  1181 	while ((file=q++)!=NULL)
       
  1182 		{
       
  1183 		if ((&file->Drive()==this) && 
       
  1184 			&file->Mount() == currentMount &&
       
  1185 			nameHash == file->NameHash() && 
       
  1186 			file->FileNameF().Match(foldedName)==KErrNone)
       
  1187 			{
       
  1188 			anEntry.iAtt = file->Att() & ~KEntryAttModified;
       
  1189 			anEntry.SetFileSize(file->CachedSize64());
       
  1190 			anEntry.iModified = file->Modified();
       
  1191 			break;
       
  1192 			}
       
  1193 		}
       
  1194 
       
  1195 
  1172 	TRACE5(UTF::EBorder, UTraceModuleFileSys::ECMountCBEntryLRet, EF32TraceUidFileSys, 
  1196 	TRACE5(UTF::EBorder, UTraceModuleFileSys::ECMountCBEntryLRet, EF32TraceUidFileSys, 
  1173 		KErrNone, anEntry.iAtt, 
  1197 		KErrNone, anEntry.iAtt, 
  1174 		I64LOW(anEntry.iModified.Int64()), I64HIGH(anEntry.iModified.Int64()), 
  1198 		I64LOW(anEntry.iModified.Int64()), I64HIGH(anEntry.iModified.Int64()), 
  1175 		anEntry.iSize);
  1199 		anEntry.iSize);
  1176 
  1200 
  1177 	}
  1201 	}
  1178 
  1202 
  1179 TInt TDrive::CheckAttributes(const TDesC& aName,TUint& aSetAttMask,TUint& aClearAttMask)
  1203 TInt TDrive::CheckAttributes(TUint& aSetAttMask,TUint& aClearAttMask)
  1180 //
  1204 //
  1181 // Validate the changes against the current entry attributes
  1205 // Validate the changes against the current entry attributes
  1182 //
  1206 //
  1183 	{
  1207 	{
  1184 
  1208 	ValidateAtts(aSetAttMask,aClearAttMask);
  1185 	TEntry entry;
       
  1186 	TRAPD(r,DoEntryL(aName,entry));
       
  1187 	if (r!=KErrNone)
       
  1188 		return(r);
       
  1189 	ValidateAtts(entry.iAtt,aSetAttMask,aClearAttMask);
       
  1190 	return(KErrNone);
  1209 	return(KErrNone);
  1191 	}
  1210 	}
  1192 
  1211 
  1193 TInt TDrive::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask)
  1212 TInt TDrive::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask)
  1194 //
  1213 //
  1201 		return(r);
  1220 		return(r);
  1202 	TPtrC entryName(StripBackSlash(aName));
  1221 	TPtrC entryName(StripBackSlash(aName));
  1203 	CFileCB* pF=LocateFile(entryName);
  1222 	CFileCB* pF=LocateFile(entryName);
  1204 	if (pF!=NULL)
  1223 	if (pF!=NULL)
  1205 		return(KErrInUse);
  1224 		return(KErrInUse);
  1206 	r=CheckAttributes(entryName,aSetAttMask,aClearAttMask);
  1225 	r=CheckAttributes(aSetAttMask,aClearAttMask);
  1207 	if (r!=KErrNone)
  1226 	if (r!=KErrNone)
  1208 		return(r);
  1227 		return(r);
  1209 	if (IsWriteProtected())
  1228 	if (IsWriteProtected())
  1210 		return(KErrAccessDenied);
  1229 		return(KErrAccessDenied);
  1211 	TTime nullTime(0);
  1230 	TTime nullTime(0);