1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\inc\f32fsys.inl
18 #define __IS_DRIVETHREAD() {__ASSERT_DEBUG(IsDriveThread(),DriveFault(ETrue));}
19 #define __IS_MAINTHREAD() {__ASSERT_DEBUG(IsMainThread(),DriveFault(EFalse));}
22 //---------------------------------------------------------------------------------------------------------------------------------
26 Gets last error reason.
28 @return TInt Returns last error reason.
30 inline TInt TDrive::GetReason() const
39 Sets a flag to state that the drive contents has changed.
41 @param aValue True if contents has changed; False if unchanged.
43 inline void TDrive::SetChanged(TBool aValue)
45 // __IS_DRIVETHREAD();//scan drive running in new thread
53 Determines whether the drive content has changed.
55 @return True if contents changed , False if unchanged.
57 inline TBool TDrive::IsChanged() const
59 // __IS_DRIVETHREAD();
67 Returns the drive number.
69 @return The drive number.
73 inline TInt TDrive::DriveNumber() const
74 {return(iDriveNumber);}
80 Determines whether the drive is mounted.
82 @return True if drive is mounted, False if drive is not mounted.
84 inline TBool TDrive::IsMounted() const
87 return(iCurrentMount!=NULL);
94 Determines whether attribute is set to local.
96 @return True if attribute is set to KDriveAttLocal, False for all other attributes.
98 inline TBool TDrive::IsLocal() const
99 {return(iAtt & KDriveAttLocal);}
105 Determines whether the drive is ROM drive.
107 @return True if drive attribute is set as ROM drive , False if not set as ROM drive.
109 inline TBool TDrive::IsRom() const
110 {return( iAtt & KDriveAttRom);}
116 Determines whether the drive is removable.
118 @return True if drive attribute is set to removable , False for all other attributes.
120 inline TBool TDrive::IsRemovable() const
121 {return( iAtt & KDriveAttRemovable);}
127 Determines whether the drive is substed.
129 @return True if drive attribute is set to substed (KDriveAttSubsted), False for all other attributes.
131 inline TBool TDrive::IsSubsted() const
132 {return( iAtt & KDriveAttSubsted);}// KDriveAttSubsted = 0x08
138 Gets a reference to the object representing the current mount.
140 @return The file's mount.
142 inline CMountCB& TDrive::CurrentMount() const
145 return(*iCurrentMount);
152 Gets the substed drive.
154 @return A pointer to the drive which is substed.
156 inline TDrive& TDrive::SubstedDrive()const
159 return(*iSubstedDrive);
167 Sets the drive as substed to the path set by an earlier call to SetSubst().
169 @param aDrive A pointer to the drive on which the volume is mounted.
172 inline void TDrive::SetSubstedDrive(TDrive* aDrive)
175 iSubstedDrive=aDrive;
182 Gets the substed path set by an earlier call to SetSubst().
184 @return A reference to a heap descriptor containing the substed path.
186 inline HBufC& TDrive::Subst() const
196 Assigns a path to a drive.
198 @param aSubst Path will be assigned to a drive.
201 inline void TDrive::SetSubst(HBufC* aSubst)
211 Gets a reference to the object representing the mount on which the file resides.
213 @return The Drives's mount.
216 inline CFsObjectCon& TDrive::Mount() const
220 Gets a reference to the object representing the file system
222 @return The reference to file system.
225 inline CFileSystem& TDrive::FSys()
229 Gets the object representing the file system
231 @return The file system.
234 inline CFileSystem*& TDrive::GetFSys()
238 Gets the object representing the TDriveExtInfo.
240 @return The Drive extension information object.
245 inline TDriveExtInfo& TDrive::ExtInfo()
251 Sets the notification flag ON. The client will receive notifications on Read or Write
252 failures from the file system.
255 inline void TDrive::SetNotifyOn()
258 iDriveFlags &= ~ENotifyOff;
261 Sets the notification flag OFF. The client will not receive notifications on Read or Write
262 failures from the file system.
265 inline void TDrive::SetNotifyOff()
268 iDriveFlags |= ENotifyOff;
272 Locks the drive.This function acquires iLock mutex.
275 inline void TDrive::Lock()
279 UnLocks the drive.This function signals the iLock mutex.
283 inline void TDrive::UnLock()
289 Gets the reserved space of a drive
291 @return Amount of space reserved in bytes.
295 inline TInt TDrive::ReservedSpace() const
296 {return iReservedSpace;}
300 Reserves a space of a drive.
302 @param aReservedSpace Amount of space to reserve in bytes.
305 inline void TDrive::SetReservedSpace(const TInt aReservedSpace)
306 {iReservedSpace=aReservedSpace; }
310 Sets the rugged flag in the drive object.
312 @param Flag to set or clear the rugged flag.
317 inline void TDrive::SetRugged(TBool aIsRugged)
320 iDriveFlags |= ENotRugged;
322 iDriveFlags &= ~ENotRugged;
327 Returns whether the current drive is running as rugged Fat
328 or not.If IsRugged flag is set then in the event of power
329 failure fat/metadata will be in a valid state if the scandrive
330 utility is run immediately after.
332 @return Is rugged fat flag.
335 inline TBool TDrive::IsRugged() const
336 {return !(iDriveFlags & ENotRugged); }
340 @return ETrue if the drive is synchronous, i.e. runs in the main file server thread.
342 inline TBool TDrive::IsSynchronous() const
344 return iDriveFlags & EDriveIsSynch;
348 Set or reset internal EDriveIsSynch flag for the TDrive.
350 inline void TDrive::SetSynchronous(TBool aIsSynch)
353 iDriveFlags |= EDriveIsSynch;
355 iDriveFlags &= ~EDriveIsSynch;
363 Gets a reference to the object representing the drive on which
364 the volume is mounted.
366 @return The drive on which the volume is mounted.
368 inline TDrive& CMountCB::Drive() const
375 Sets a pointer to the object representing the drive on which
376 the volume is mounted.
378 @param aDrive A pointer to the drive on which the volume is mounted.
380 inline void CMountCB::SetDrive(TDrive* aDrive)
387 Gets a reference to a heap descriptor containing the name of
390 @return A reference to a heap descriptor containing the volume name.
392 inline HBufC& CMountCB::VolumeName() const
393 {return(*iVolumeName);}
399 Sets a pointer to a heap descriptor containing the name of the mounted volume.
401 @param aName A pointer to a heap descriptor containing the name of
402 the mounted volume to be set.
404 inline void CMountCB::SetVolumeName(HBufC* aName)
411 Tests whether the client is notified of any read or write failures.
413 The notification status is a property of the current session with
414 the file server, the value of which is stored in CSessionFs::iNotifyUser.
415 If set to true, the client will receive notifications from the file system.
417 Typically, this function might be used to save the current notification
418 state prior to temporarily disabling notifiers. This allows the original
419 notification state to be restored.
421 Note that GetNotifyUser() is only available once the drive has been set for
422 the mount control block (using SetDrive()), since the notification status
423 is held by the session and accessed via the drive.
425 @return True if the client receives notifications from the file system,
428 inline TBool CMountCB::GetNotifyUser() const
429 {return(Drive().GetNotifyUser());}
436 inline void CMountCB::SetNotifyOn()
437 {Drive().SetNotifyOn();}
444 inline void CMountCB::SetNotifyOff()
445 {Drive().SetNotifyOff();}
451 Locks the mount by incrementing the internal lock counter.
453 The mount becomes locked on formatting or on the opening of a resource
454 (a file or a directory) or raw disk subsession.
455 A format, resource or raw disk subsession can only be opened if the mount
458 inline void CMountCB::IncLock()
465 Unlocks the mount by decrementing the internal lock counter.
467 The mount becomes locked on formatting or on the opening of a resource
468 (a file or a directory) or raw disk subsession.
469 A format, resource or raw disk subsession can only be opened if the mount
472 inline void CMountCB::DecLock()
479 Gets the current lock status.
481 It delivers the current lock status by returning the internal lock counter.
483 @return The current lock status.
485 inline TInt CMountCB::LockStatus() const
486 {return(iLockMount);}
492 Tests whether the mount is currently locked.
494 A mount is locked when the internal lock counter is greater than zero.
495 On creation, the lock counter is set to zero.
497 The mount becomes locked on formatting or on the opening of a resource
498 (a file or a directory) or raw disk subsession.
499 A format, resource or raw disk subsession can only be opened if the mount
502 @return True if the mount is locked, false, otherwise.
504 inline TBool CMountCB::Locked() const
505 {return iLockMount>0; }
511 Tests whether the mount control block represents the current mount on
512 the associated drive.
514 A drive has only one mount which is accessible: the current mount.
515 Any mount other than the current mount relates to a partition (i.e. volume)
516 that was present on a removable media which has since been removed.
517 The reason the mount has persisted is because resources (i.e. files/directories)
518 are still open on it.
520 This function is only available when the drive has been set for the mount
521 control block (using SetDrive()), since the current mount is held by the drive.
523 @return True if the mount is the current mount on the drive, false otherwise.
525 inline TBool CMountCB::IsCurrentMount() const
526 {return(this==&iDrive->CurrentMount());}
533 inline TInt64 CMountCB::Size() const
540 Set the unique mount number
541 @param aMountNumber - The unique mount number
543 const TInt KMountDismounted = 0x80000000;
544 inline void CMountCB::SetMountNumber(TInt aMountNumber)
545 { iMountNumber = (aMountNumber &~ KMountDismounted); }
551 Set the mount to be dismounted
553 inline void CMountCB::SetDismounted(TBool aDismounted)
556 iMountNumber |= KMountDismounted;
558 iMountNumber &= ~KMountDismounted;
565 Returns the unique mount number
566 @return The unique mount number
568 inline TInt CMountCB::MountNumber() const
569 { return(iMountNumber &~ KMountDismounted); }
575 Returns ETrue if the mount is flagged as dismounted.
576 @return ETrue if the mount is flagged as dismounted
578 inline TBool CMountCB::IsDismounted() const
579 { return(iMountNumber & KMountDismounted); }
584 Retrieves TBusLocalDrive object associated with the mount
586 inline TInt CMountCB::LocalDrive(TBusLocalDrive*& aLocalDrive)
589 return GetInterface(EGetLocalDrive, (TAny*&) aLocalDrive, NULL);
592 inline TInt CMountCB::AddToCompositeMount(TInt aMountIndex)
594 TAny *mountInterface = NULL;
595 return(GetInterface(EAddToCompositeMount, mountInterface, (TAny*)aMountIndex));
599 Returns whether the mount (and any extensions) support file caching
601 inline TInt CMountCB::LocalBufferSupport(CFileCB* aFile)
603 TAny* dummyInterface;
604 return GetInterface(ELocalBufferSupport, dummyInterface, aFile);
607 inline TInt CMountCB::MountControl(TInt /*aLevel*/, TInt /*aOption*/, TAny* /*aParam*/)
609 return KErrNotSupported;
613 inline void CMountCB::FinaliseMountL(TInt aOperation, TAny* /*aParam1=NULL*/, TAny* /*aParam2=NULL*/)
615 if(aOperation == RFs::EFinal_RW)
616 {//-- call the legacy method
621 User::Leave(KErrNotSupported);
624 inline TInt CMountCB::CheckDisk(TInt /*aOperation*/, TAny* /*aParam1=NULL*/, TAny* /*aParam2=NULL*/)
626 return(KErrNotSupported);
629 inline TInt CMountCB::ScanDrive(TInt /*aOperation*/, TAny* /*aParam1=NULL*/, TAny* /*aParam2=NULL*/)
631 return(KErrNotSupported);
634 //---------------------------------------------------------------------------------------------------------------------------------
638 Sets the mount associated with the file.
640 @param aMount The mount.
642 inline void CFileCB::SetMount(CMountCB * aMount)
646 Gets a reference to the object representing the drive on which
649 @return A reference to the file's drive.
651 inline TDrive& CFileCB::Drive() const
658 Gets a reference to the object representing the drive on which the file was created.
660 The 'created drive' is only different from the 'drive', as returned by Drive(), if
661 the 'drive' was a substitute for the 'created drive' in the file server session.
663 @return A reference to the drive on which the file was created.
665 inline TDrive& CFileCB::CreatedDrive() const
666 {return(*iCreatedDrive);}
672 Gets a reference to the object representing the mount on which the file resides.
674 @return The file's mount.
676 inline CMountCB& CFileCB::Mount() const
683 Gets a reference to a heap descriptor containing the full file name.
685 @return A heap descriptor containing the full file name.
687 inline HBufC& CFileCB::FileName() const
688 {return(*iFileName);}
691 Gets a reference to a heap descriptor containing the folded full file name.
693 @return A heap descriptor containing the full file name.
695 inline HBufC& CFileCB::FileNameF() const
696 {return(*iFileNameF);}
699 Gets the hash of the folded filename
701 @return hash of the folded file name
703 inline TUint32 CFileCB::NameHash() const
708 Gets a reference to the file share lock being used by the file.
710 @return The file share lock.
712 inline RArray<SFileShareLock>& CFileCB::Lock()
719 Gets the file object's unique ID, as returned by CObject::UniqueID().
721 @return The object's unique ID.
725 inline TInt CFileCB::UniqueID() const
726 {return(CFsObject::UniqueID());}
732 Gets the iShare value, which defines the level of access allowed to the file.
734 @return The value of iShare
738 inline TShare CFileCB::Share() const
745 Sets the iShare value, which defines the level of access allowed to the file.
747 @param aShare The new value.
751 inline void CFileCB::SetShare(TShare aShare)
758 Gets the size of the file.
760 @return The size of the file.
762 inline TInt CFileCB::Size() const
769 Sets the size of the file.
771 @param aSize The size of the file.
773 inline void CFileCB::SetSize(TInt aSize)
780 Gets the file's attributes.
782 @return An integer containing the file attribute bit mask.
784 inline TInt CFileCB::Att() const
791 Sets the file's attributes.
793 @param aAtt The file attribute bit mask.
795 inline void CFileCB::SetAtt(TInt aAtt)
802 Gets the universal time when the file was last modified.
804 @return The universal time when the file was last modiified.
806 inline TTime CFileCB::Modified() const
813 Sets the universal time when the file was last modified.
815 @param aModified The universal time when the file was last modified.
817 inline void CFileCB::SetModified(TTime aModified)
818 {iModified=aModified;}
824 Tests whether the file is corrupt.
826 @return ETrue if the file is corrupt; EFalse otherwise.
828 inline TBool CFileCB::FileCorrupt() const
829 {return iFileCorrupt;}
835 Sets whether the file is corrupt.
837 @param aFileCorrupt ETrue, if the file is corrupt; EFalse, otherwise.
839 inline void CFileCB::SetFileCorrupt(TBool aFileCorrupt)
840 {iFileCorrupt=aFileCorrupt;}
846 Gets the iBadPower value.
848 @return The value of iBadPower
850 @see CFileCB::iBadPower
852 inline TBool CFileCB::BadPower() const
853 {return (iBadPower);}
859 Sets the iBadPower value.
861 @param aBadPower ETrue, if an operation on the file has failed due
863 EFalse if power has been found to be good.
865 @see CFileCB::iBadPower
867 inline void CFileCB::SetBadPower(TBool aBadPower)
868 {iBadPower=aBadPower;}
872 Retrieves the BlockMap of a file.
882 inline TInt CFileCB::BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos)
885 TInt r = GetInterface(EBlockMapInterface, pM, (TAny*) this);
888 return reinterpret_cast<CFileCB::MBlockMapInterface*>(pM)->BlockMap(aInfo, aStartPos, aEndPos);
893 Retrieves TBusLocalDrive object associated with an open file.
895 inline TInt CFileCB::LocalDrive(TBusLocalDrive*& aLocalDrive)
898 return GetInterface(EGetLocalDrive, (TAny*&) aLocalDrive, NULL);
901 //---------------------------------------------------------------------------------------------------------------------------------
902 // Class RLocalMessage
903 inline RLocalMessage::RLocalMessage()
904 {iHandle = KLocalMessageHandle; iFunction=-1;}
906 //---------------------------------------------------------------------------------------------------------------------------------
909 Gets a reference to the object representing an open file that is being shared.
911 @return A reference to the shared file.
913 inline CFileCB& CFileShare::File()
917 //---------------------------------------------------------------------------------------------------------------------------------
921 Gets a reference to the object representing the drive on which
922 the directory resides.
924 @return A reference to the directory's drive.
926 inline TDrive& CDirCB::Drive() const
933 Gets a reference to the object representing the mount on which
934 the directory resides.
936 @return A reference to the directory's mount.
938 inline CMountCB& CDirCB::Mount() const
945 Tests whether the preceding entry details should be returned when
946 multiple entries are being read.
948 @return True if the preceding entry details should be returned;
951 inline TBool CDirCB::Pending() const
958 Sets whether the preceding entry details should be returned when
959 multiple entries are being read.
961 @param aPending ETrue if the preceding entry details should be returned;
964 inline void CDirCB::SetPending(TBool aPending)
969 //---------------------------------------------------------------------------------------------------------------------------------
973 Gets the object representing the drive on which the disk to
974 be formatted resides.
976 @return The drive for the format action.
978 inline TDrive& CFormatCB::Drive() const
985 Gets the object representing the mount on which the disk to
986 be formatted resides.
988 @return The mount for the format action.
990 inline CMountCB& CFormatCB::Mount() const
997 Gets the mode of the format operation.
999 @return The value of the format mode.
1001 inline TFormatMode CFormatCB::Mode() const
1008 Gets the current stage in the format operation.
1010 @return The stage the current format operation has reached.
1012 inline TInt& CFormatCB::CurrentStep()
1013 {return(iCurrentStep);}
1017 //---------------------------------------------------------------------------------------------------------------------------------
1021 Gets a reference to an object representing the drive on which the disk resides.
1023 @return A reference to the drive on which the disk resides.
1025 inline TDrive& CRawDiskCB::Drive()
1026 {return(iMount->Drive());}
1032 Gets an object representing the mount on which the disk resides.
1034 @return The mount on which the disk resides.
1036 inline CMountCB& CRawDiskCB::Mount()
1043 Tests whether the mount on which the disk resides is write protected.
1045 @return True if the mount is write protected, false otherwise.
1047 inline TBool CRawDiskCB::IsWriteProtected() const
1048 { return(iFlags & EWriteProtected); }
1055 Stores the write protected state of the disk.
1057 inline void CRawDiskCB::SetWriteProtected()
1058 { iFlags |= EWriteProtected; }
1064 Tests whether the disk contents has changed (due to a write operation)
1066 @return True if the disk contents has changed
1068 inline TBool CRawDiskCB::IsChanged() const
1069 { return(iFlags & EChanged); }
1075 Set a flag to state that the disk contents has changed (due to a write operation)
1077 inline void CRawDiskCB::SetChanged()
1078 { iFlags |= EChanged; }
1082 //---------------------------------------------------------------------------------------------------------------------------------
1083 // class CProxyDriveFactory
1085 Sets the Library (DLL) handle to be used by the CProxyDriveFactory
1087 inline void CProxyDriveFactory::SetLibrary(RLibrary aLib)
1090 Gets the Library (DLL) handle in use by the CProxyDriveFactory
1091 @return Library (DLL) handle
1093 inline RLibrary CProxyDriveFactory::Library() const
1096 //---------------------------------------------------------------------------------------------------------------------------------
1097 // class CProxyDrive
1099 Gets the mount control block object for a specific volume on a drive.
1101 @return either a currently mounted volume in the system or the volume that has been removed but still has
1102 subsession objects open.
1104 inline CMountCB* CProxyDrive::Mount() const
1109 Returns wheher the drive (and any extensions) support file caching
1111 inline TInt CProxyDrive::LocalBufferSupport()
1113 TAny* dummyInterface;
1114 return GetInterface(ELocalBufferSupport, dummyInterface, NULL);
1118 return whether proxy drive supports file caching
1120 inline TInt CBaseExtProxyDrive::LocalBufferSupport()
1122 return iProxy->LocalBufferSupport();
1125 //---------------------------------------------------------------------------------------------------------------------------------
1126 // class CLocDrvMountCB
1128 Gets the mounted local drive object
1130 @return The local drive.
1132 inline CProxyDrive* CLocDrvMountCB::LocalDrive() const
1133 {return(iProxyDrive);}
1135 inline TDismountParams::TDismountParams(TInt aDriveNumber, TDrive* aDrivePointer, TBool aForcedDismount, RMessage2* aForcedMessage)
1137 iDriveNumber = aDriveNumber;
1138 iDrivePointer = aDrivePointer;
1139 iForcedDismount = aForcedDismount;
1140 iForcedMessage = aForcedMessage;
1143 //---------------------------------------------------------------------------------------------------------------------------------
1145 inline CFsObjectCon* CFsObject::Container() const
1146 {return iContainer;}
1147 inline TInt CFsObject::Inc()
1148 {return(User::SafeInc(iAccessCount));}
1149 inline TInt CFsObject::Dec()
1150 {return(User::SafeDec(iAccessCount));}