Update contrib.
1 // Copyright (c) 1998-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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfat\inc\fat_dir_entry.inl
23 #if !defined(FAT_DIR_ENTRY_INL)
24 #define FAT_DIR_ENTRY_INL
26 //-------------------------------------------------------------------------------------------------------------------
30 Defined cast of Fat directory entry data read to structure allowing access to data
32 #define pDir ((SFatDirEntry*)&iData[0])
35 inline TFatDirEntry::TFatDirEntry()
40 /** zero-fill the entry contents */
41 inline void TFatDirEntry::InitZ()
43 Mem::FillZ(iData, KSizeOfFatDirEntry);
47 Return the Dos name of a directory entry
49 @return A descriptor containing the Dos name of a directory entry
51 inline const TPtrC8 TFatDirEntry::Name() const
52 {return TPtrC8((TUint8*)&(pDir->iName),KFatDirNameSize);}
54 @return The attributes for the Directory entry
56 inline TInt TFatDirEntry::Attributes() const
57 {return pDir->iAttributes;}
59 @param aOffset This offset will be subtracted from the returned time.
60 @return Time of file modification
62 inline TTime TFatDirEntry::Time(TTimeIntervalSeconds aOffset) const
64 TTime time=DosTimeToTTime(pDir->iTime,pDir->iDate);
68 @return The Start cluster for the file or directory for this entry
70 inline TInt TFatDirEntry::StartCluster() const
72 const TUint16 KStClustMaskHi = 0x0FFF;
73 return ((pDir->iStartClusterHi & KStClustMaskHi) << 16) | pDir->iStartClusterLo;
77 @return The size of file or directory for this entry
79 inline TUint32 TFatDirEntry::Size() const
82 @return True if the entry is erased
84 inline TBool TFatDirEntry::IsErased() const
85 {return (TBool)(iData[0]==KEntryErasedMarker);}
87 @return True if the entry refers to the current directory
89 inline TBool TFatDirEntry::IsCurrentDirectory() const
90 {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KBlankSpace);}
92 @return True if the Entry refers to the parent directory
94 inline TBool TFatDirEntry::IsParentDirectory() const
95 {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KDotEntryByte);}
97 @return True if end of directory
99 inline TBool TFatDirEntry::IsEndOfDirectory() const
100 {return (TBool)(iData[0]==0x00);}
102 Set the Dos name of a directory entry
104 @param aDes A descriptor containg the name
106 inline void TFatDirEntry::SetName(const TDesC8& aDes)
108 __ASSERT_DEBUG(aDes.Length()<=KFatDirNameSize,Fault(EFatBadDirEntryParameter));
109 TPtr8 name(pDir->iName,KFatDirNameSize);
113 Set the file or directory attributes for this entry
115 @param anAtts The file or directory attributes
117 inline void TFatDirEntry::SetAttributes(TInt anAtts)
119 __ASSERT_DEBUG(!(anAtts&~KMaxTUint8),Fault(EFatBadDirEntryParameter));
120 pDir->iAttributes=(TUint8)anAtts;
123 Set the modification time and date of the directory entry
125 @param aTime Modification time of the file or directory
126 @aOffset aOffset This offset will be added to the time.
128 inline void TFatDirEntry::SetTime(TTime aTime, TTimeIntervalSeconds aOffset)
131 pDir->iTime=(TUint16)DosTimeFromTTime(aTime);
132 pDir->iDate=(TUint16)DosDateFromTTime(aTime);
135 inline void TFatDirEntry::SetCreateTime(TTime aTime, TTimeIntervalSeconds aOffset)
138 pDir->iTimeC=(TUint16)DosTimeFromTTime(aTime);
139 pDir->iDateC=(TUint16)DosDateFromTTime(aTime);
143 Set the start cluster number of the file or directory refered to by the entry
145 @param aStartCluster The start cluster number
147 inline void TFatDirEntry::SetStartCluster(TInt aStartCluster)
149 pDir->iStartClusterLo=(TUint16)(aStartCluster);
150 pDir->iStartClusterHi=(TUint16)(aStartCluster >> 16);
153 Set the size of the file or directory refered to by the entry
155 @param aFileSize Size of the file
157 inline void TFatDirEntry::SetSize(TUint32 aFileSize)
158 {pDir->iSize=aFileSize;}
160 Set the directory entry as erased
162 inline void TFatDirEntry::SetErased()
163 {iData[0]=KEntryErasedMarker;}
165 Set the current entry to refer to the current directory
167 inline void TFatDirEntry::SetCurrentDirectory()
170 Mem::Fill(&iData[1],KFatDirNameSize-1,' ');
173 Set the current entry to refer to the parent directory
175 inline void TFatDirEntry::SetParentDirectory()
177 iData[0]='.';iData[1]='.';
178 Mem::Fill(&iData[2],KFatDirNameSize-2,' ');
181 Set the current entry to be the end of directory marker
183 inline void TFatDirEntry::SetEndOfDirectory()
184 {Mem::FillZ(&iData[0],KFatDirNameSize);}
187 Get VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries
188 Uses 1 byte from "Last Access Date" field, offset 19. Hack.
190 TUint TFatDirEntry::RuggedFatEntryId() const
192 return pDir->iReserved2;
196 Set VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries
197 Uses 1 byte from "Last Access Date" field, offset 19. Hack.
199 void TFatDirEntry::SetRuggedFatEntryId(TUint16 aId)
201 pDir->iReserved2 = aId;
206 @return True if the entry is the start of a long name set of entries
208 inline TBool TFatDirEntry::IsLongNameStart() const
209 {return (TBool)((iData[0]&0x40) != 0);}
211 @return True is the Entry is a VFat entry
213 inline TBool TFatDirEntry::IsVFatEntry() const
214 {return (TBool)(Attributes()==KVFatEntryAttribute && IsEndOfDirectory()==EFalse);}
216 @return The number of following VFat entries
218 inline TInt TFatDirEntry::NumFollowing() const
219 {return (iData[0]&0x3F);}
222 inline TUint8 TFatDirEntry::CheckSum() const
224 ASSERT(IsVFatEntry());
231 @return ETrue if the Directory entry contains garbage data
233 inline TBool TFatDirEntry::IsGarbage() const
235 return (iData[0]==0xFF);
240 #endif //FAT_DIR_ENTRY_INL