sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32\sfat\inc\fat_dir_entry.inl sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!! sl@0: //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it sl@0: //!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: sl@0: sl@0: #if !defined(FAT_DIR_ENTRY_INL) sl@0: #define FAT_DIR_ENTRY_INL sl@0: sl@0: //------------------------------------------------------------------------------------------------------------------- sl@0: sl@0: sl@0: /** sl@0: Defined cast of Fat directory entry data read to structure allowing access to data sl@0: */ sl@0: #define pDir ((SFatDirEntry*)&iData[0]) sl@0: sl@0: sl@0: inline TFatDirEntry::TFatDirEntry() sl@0: { sl@0: InitZ(); sl@0: } sl@0: sl@0: /** zero-fill the entry contents */ sl@0: inline void TFatDirEntry::InitZ() sl@0: { sl@0: Mem::FillZ(iData, KSizeOfFatDirEntry); sl@0: } sl@0: sl@0: /** sl@0: Return the Dos name of a directory entry sl@0: sl@0: @return A descriptor containing the Dos name of a directory entry sl@0: */ sl@0: inline const TPtrC8 TFatDirEntry::Name() const sl@0: {return TPtrC8((TUint8*)&(pDir->iName),KFatDirNameSize);} sl@0: /** sl@0: @return The attributes for the Directory entry sl@0: */ sl@0: inline TInt TFatDirEntry::Attributes() const sl@0: {return pDir->iAttributes;} sl@0: /** sl@0: @param aOffset This offset will be subtracted from the returned time. sl@0: @return Time of file modification sl@0: */ sl@0: inline TTime TFatDirEntry::Time(TTimeIntervalSeconds aOffset) const sl@0: { sl@0: TTime time=DosTimeToTTime(pDir->iTime,pDir->iDate); sl@0: return time-=aOffset; sl@0: } sl@0: /** sl@0: @return The Start cluster for the file or directory for this entry sl@0: */ sl@0: inline TInt TFatDirEntry::StartCluster() const sl@0: { sl@0: const TUint16 KStClustMaskHi = 0x0FFF; sl@0: return ((pDir->iStartClusterHi & KStClustMaskHi) << 16) | pDir->iStartClusterLo; sl@0: } sl@0: sl@0: /** sl@0: @return The size of file or directory for this entry sl@0: */ sl@0: inline TUint32 TFatDirEntry::Size() const sl@0: {return pDir->iSize;} sl@0: /** sl@0: @return True if the entry is erased sl@0: */ sl@0: inline TBool TFatDirEntry::IsErased() const sl@0: {return (TBool)(iData[0]==KEntryErasedMarker);} sl@0: /** sl@0: @return True if the entry refers to the current directory sl@0: */ sl@0: inline TBool TFatDirEntry::IsCurrentDirectory() const sl@0: {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KBlankSpace);} sl@0: /** sl@0: @return True if the Entry refers to the parent directory sl@0: */ sl@0: inline TBool TFatDirEntry::IsParentDirectory() const sl@0: {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KDotEntryByte);} sl@0: /** sl@0: @return True if end of directory sl@0: */ sl@0: inline TBool TFatDirEntry::IsEndOfDirectory() const sl@0: {return (TBool)(iData[0]==0x00);} sl@0: /** sl@0: Set the Dos name of a directory entry sl@0: sl@0: @param aDes A descriptor containg the name sl@0: */ sl@0: inline void TFatDirEntry::SetName(const TDesC8& aDes) sl@0: { sl@0: __ASSERT_DEBUG(aDes.Length()<=KFatDirNameSize,Fault(EFatBadDirEntryParameter)); sl@0: TPtr8 name(pDir->iName,KFatDirNameSize); sl@0: name=aDes; sl@0: } sl@0: /** sl@0: Set the file or directory attributes for this entry sl@0: sl@0: @param anAtts The file or directory attributes sl@0: */ sl@0: inline void TFatDirEntry::SetAttributes(TInt anAtts) sl@0: { sl@0: __ASSERT_DEBUG(!(anAtts&~KMaxTUint8),Fault(EFatBadDirEntryParameter)); sl@0: pDir->iAttributes=(TUint8)anAtts; sl@0: } sl@0: /** sl@0: Set the modification time and date of the directory entry sl@0: sl@0: @param aTime Modification time of the file or directory sl@0: @aOffset aOffset This offset will be added to the time. sl@0: */ sl@0: inline void TFatDirEntry::SetTime(TTime aTime, TTimeIntervalSeconds aOffset) sl@0: { sl@0: aTime+=aOffset; sl@0: pDir->iTime=(TUint16)DosTimeFromTTime(aTime); sl@0: pDir->iDate=(TUint16)DosDateFromTTime(aTime); sl@0: } sl@0: sl@0: inline void TFatDirEntry::SetCreateTime(TTime aTime, TTimeIntervalSeconds aOffset) sl@0: { sl@0: aTime+=aOffset; sl@0: pDir->iTimeC=(TUint16)DosTimeFromTTime(aTime); sl@0: pDir->iDateC=(TUint16)DosDateFromTTime(aTime); sl@0: } sl@0: sl@0: /** sl@0: Set the start cluster number of the file or directory refered to by the entry sl@0: sl@0: @param aStartCluster The start cluster number sl@0: */ sl@0: inline void TFatDirEntry::SetStartCluster(TInt aStartCluster) sl@0: { sl@0: pDir->iStartClusterLo=(TUint16)(aStartCluster); sl@0: pDir->iStartClusterHi=(TUint16)(aStartCluster >> 16); sl@0: } sl@0: /** sl@0: Set the size of the file or directory refered to by the entry sl@0: sl@0: @param aFileSize Size of the file sl@0: */ sl@0: inline void TFatDirEntry::SetSize(TUint32 aFileSize) sl@0: {pDir->iSize=aFileSize;} sl@0: /** sl@0: Set the directory entry as erased sl@0: */ sl@0: inline void TFatDirEntry::SetErased() sl@0: {iData[0]=KEntryErasedMarker;} sl@0: /** sl@0: Set the current entry to refer to the current directory sl@0: */ sl@0: inline void TFatDirEntry::SetCurrentDirectory() sl@0: { sl@0: iData[0]='.'; sl@0: Mem::Fill(&iData[1],KFatDirNameSize-1,' '); sl@0: } sl@0: /** sl@0: Set the current entry to refer to the parent directory sl@0: */ sl@0: inline void TFatDirEntry::SetParentDirectory() sl@0: { sl@0: iData[0]='.';iData[1]='.'; sl@0: Mem::Fill(&iData[2],KFatDirNameSize-2,' '); sl@0: } sl@0: /** sl@0: Set the current entry to be the end of directory marker sl@0: */ sl@0: inline void TFatDirEntry::SetEndOfDirectory() sl@0: {Mem::FillZ(&iData[0],KFatDirNameSize);} sl@0: sl@0: /** sl@0: Get VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries sl@0: Uses 1 byte from "Last Access Date" field, offset 19. Hack. sl@0: */ sl@0: TUint TFatDirEntry::RuggedFatEntryId() const sl@0: { sl@0: return pDir->iReserved2; sl@0: } sl@0: sl@0: /** sl@0: Set VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries sl@0: Uses 1 byte from "Last Access Date" field, offset 19. Hack. sl@0: */ sl@0: void TFatDirEntry::SetRuggedFatEntryId(TUint16 aId) sl@0: { sl@0: pDir->iReserved2 = aId; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @return True if the entry is the start of a long name set of entries sl@0: */ sl@0: inline TBool TFatDirEntry::IsLongNameStart() const sl@0: {return (TBool)((iData[0]&0x40) != 0);} sl@0: /** sl@0: @return True is the Entry is a VFat entry sl@0: */ sl@0: inline TBool TFatDirEntry::IsVFatEntry() const sl@0: {return (TBool)(Attributes()==KVFatEntryAttribute && IsEndOfDirectory()==EFalse);} sl@0: /** sl@0: @return The number of following VFat entries sl@0: */ sl@0: inline TInt TFatDirEntry::NumFollowing() const sl@0: {return (iData[0]&0x3F);} sl@0: sl@0: sl@0: inline TUint8 TFatDirEntry::CheckSum() const sl@0: { sl@0: ASSERT(IsVFatEntry()); sl@0: return iData[13]; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: @return ETrue if the Directory entry contains garbage data sl@0: */ sl@0: inline TBool TFatDirEntry::IsGarbage() const sl@0: { sl@0: return (iData[0]==0xFF); sl@0: } sl@0: sl@0: sl@0: sl@0: #endif //FAT_DIR_ENTRY_INL sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: