userlibandfileserver/fileserver/sfile/sf_drv.cpp
changeset 201 43365a9b78a3
parent 152 657f875b013e
child 199 189ece41fa29
equal deleted inserted replaced
200:73ea206103e6 201:43365a9b78a3
    83 		aRequest->SetDrive(&aRequest->Drive()->SubstedDrive());
    83 		aRequest->SetDrive(&aRequest->Drive()->SubstedDrive());
    84 		}
    84 		}
    85 	return(KErrNone);
    85 	return(KErrNone);
    86 	}
    86 	}
    87 
    87 
    88 void ValidateAtts(TUint /*anEntryAtts*/,TUint& aSetAttMask,TUint& aClearAttMask)
    88 void ValidateAtts(TUint& aSetAttMask,TUint& aClearAttMask)
    89 //
    89 //
    90 // Do not allow the entry type to be changed
    90 // Do not allow the entry type to be changed
    91 //
    91 //
    92 	{
    92 	{
    93 	const TUint KReadOnlySetAtts = KEntryAttVolume | 
    93 	const TUint KReadOnlySetAtts = KEntryAttVolume | 
  1167 void TDrive::DoEntryL(const TDesC& aName, TEntry& anEntry)
  1167 void TDrive::DoEntryL(const TDesC& aName, TEntry& anEntry)
  1168 //
  1168 //
  1169 // Get entry details
  1169 // Get entry details
  1170 //
  1170 //
  1171 	{
  1171 	{
  1172 	FlushCachedFileInfoL();
       
  1173 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYL, "drive %d", DriveNumber());
  1172 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYL, "drive %d", DriveNumber());
  1174 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYL_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
  1173 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYL_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
  1175 	CurrentMount().EntryL(aName,anEntry);
  1174 	CurrentMount().EntryL(aName,anEntry);
       
  1175 
       
  1176 	// If the file is already open then read the file attributes directly from the file
       
  1177 	TFileName foldedName;
       
  1178 	TUint32 nameHash=0;
       
  1179 	foldedName.CopyF(aName);
       
  1180 	nameHash=CalcNameHash(foldedName);
       
  1181 
       
  1182 	__CHECK_DRIVETHREAD(iDriveNumber);
       
  1183 	TDblQueIter<CFileCB> q(CurrentMount().iMountQ);
       
  1184 	CMountCB* currentMount = &CurrentMount();
       
  1185 	CFileCB* file;
       
  1186 	while ((file=q++)!=NULL)
       
  1187 		{
       
  1188 		if ((&file->Drive()==this) && 
       
  1189 			&file->Mount() == currentMount &&
       
  1190 			nameHash == file->NameHash() && 
       
  1191 			file->FileNameF().Match(foldedName)==KErrNone)
       
  1192 			{
       
  1193 			anEntry.iAtt = file->Att() & ~KEntryAttModified;
       
  1194 			anEntry.SetFileSize(file->CachedSize64());
       
  1195 			anEntry.iModified = file->Modified();
       
  1196 			break;
       
  1197 			}
       
  1198 		}
       
  1199 
       
  1200 
  1176 	OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYLRET, "att %x modified %x:%x  size %x:%x", (TUint) anEntry.iAtt, (TUint) I64HIGH(anEntry.iModified.Int64()), (TUint) I64LOW(anEntry.iModified.Int64()), (TUint) I64HIGH(anEntry.FileSize()), (TUint) anEntry.FileSize());
  1201 	OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYLRET, "att %x modified %x:%x  size %x:%x", (TUint) anEntry.iAtt, (TUint) I64HIGH(anEntry.iModified.Int64()), (TUint) I64LOW(anEntry.iModified.Int64()), (TUint) I64HIGH(anEntry.FileSize()), (TUint) anEntry.FileSize());
  1177 	}
  1202 	}
  1178 
  1203 
  1179 TInt TDrive::CheckAttributes(const TDesC& aName,TUint& aSetAttMask,TUint& aClearAttMask)
  1204 TInt TDrive::CheckAttributes(TUint& aSetAttMask,TUint& aClearAttMask)
  1180 //
  1205 //
  1181 // Validate the changes against the current entry attributes
  1206 // Validate the changes against the current entry attributes
  1182 //
  1207 //
  1183 	{
  1208 	{
  1184 
  1209 	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);
  1210 	return(KErrNone);
  1191 	}
  1211 	}
  1192 
  1212 
  1193 TInt TDrive::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask)
  1213 TInt TDrive::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask)
  1194 //
  1214 //
  1201 		return(r);
  1221 		return(r);
  1202 	TPtrC entryName(StripBackSlash(aName));
  1222 	TPtrC entryName(StripBackSlash(aName));
  1203 	CFileCB* pF=LocateFile(entryName);
  1223 	CFileCB* pF=LocateFile(entryName);
  1204 	if (pF!=NULL)
  1224 	if (pF!=NULL)
  1205 		return(KErrInUse);
  1225 		return(KErrInUse);
  1206 	r=CheckAttributes(entryName,aSetAttMask,aClearAttMask);
  1226 	r=CheckAttributes(aSetAttMask,aClearAttMask);
  1207 	if (r!=KErrNone)
  1227 	if (r!=KErrNone)
  1208 		return(r);
  1228 		return(r);
  1209 	if (IsWriteProtected())
  1229 	if (IsWriteProtected())
  1210 		return(KErrAccessDenied);
  1230 		return(KErrAccessDenied);
  1211 	TTime nullTime(0);
  1231 	TTime nullTime(0);