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 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
32 #if !defined(FAT_DIR_ENTRY_INL)
33 #define FAT_DIR_ENTRY_INL
35 //-------------------------------------------------------------------------------------------------------------------
39 Defined cast of Fat directory entry data read to structure allowing access to data
41 #define pDir ((SFatDirEntry*)&iData[0])
44 inline TFatDirEntry::TFatDirEntry()
49 /** zero-fill the entry contents */
50 inline void TFatDirEntry::InitZ()
52 Mem::FillZ(iData, KSizeOfFatDirEntry);
56 Return the Dos name of a directory entry
58 @return A descriptor containing the Dos name of a directory entry
60 inline const TPtrC8 TFatDirEntry::Name() const
61 {return TPtrC8((TUint8*)&(pDir->iName),KFatDirNameSize);}
63 @return The attributes for the Directory entry
65 inline TInt TFatDirEntry::Attributes() const
66 {return pDir->iAttributes;}
68 @param aOffset This offset will be subtracted from the returned time.
69 @return Time of file modification
71 inline TTime TFatDirEntry::Time(TTimeIntervalSeconds aOffset) const
73 TTime time=DosTimeToTTime(pDir->iTime,pDir->iDate);
77 @return The Start cluster for the file or directory for this entry
79 inline TInt TFatDirEntry::StartCluster() const
81 const TUint16 KStClustMaskHi = 0x0FFF;
82 return ((pDir->iStartClusterHi & KStClustMaskHi) << 16) | pDir->iStartClusterLo;
86 @return The size of file or directory for this entry
88 inline TUint32 TFatDirEntry::Size() const
91 @return True if the entry is erased
93 inline TBool TFatDirEntry::IsErased() const
94 {return (TBool)(iData[0]==KEntryErasedMarker);}
96 @return True if the entry refers to the current directory
98 inline TBool TFatDirEntry::IsCurrentDirectory() const
99 {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KBlankSpace);}
101 @return True if the Entry refers to the parent directory
103 inline TBool TFatDirEntry::IsParentDirectory() const
104 {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KDotEntryByte);}
106 @return True if end of directory
108 inline TBool TFatDirEntry::IsEndOfDirectory() const
109 {return (TBool)(iData[0]==0x00);}
111 Set the Dos name of a directory entry
113 @param aDes A descriptor containg the name
115 inline void TFatDirEntry::SetName(const TDesC8& aDes)
117 __ASSERT_DEBUG(aDes.Length()<=KFatDirNameSize,Fault(EFatBadDirEntryParameter));
118 TPtr8 name(pDir->iName,KFatDirNameSize);
122 Set the file or directory attributes for this entry
124 @param anAtts The file or directory attributes
126 inline void TFatDirEntry::SetAttributes(TInt anAtts)
128 __ASSERT_DEBUG(!(anAtts&~KMaxTUint8),Fault(EFatBadDirEntryParameter));
129 pDir->iAttributes=(TUint8)anAtts;
132 Set the modification time and date of the directory entry
134 @param aTime Modification time of the file or directory
135 @aOffset aOffset This offset will be added to the time.
137 inline void TFatDirEntry::SetTime(TTime aTime, TTimeIntervalSeconds aOffset)
140 pDir->iTime=(TUint16)DosTimeFromTTime(aTime);
141 pDir->iDate=(TUint16)DosDateFromTTime(aTime);
144 inline void TFatDirEntry::SetCreateTime(TTime aTime, TTimeIntervalSeconds aOffset)
147 pDir->iTimeC=(TUint16)DosTimeFromTTime(aTime);
148 pDir->iDateC=(TUint16)DosDateFromTTime(aTime);
152 Set the start cluster number of the file or directory refered to by the entry
154 @param aStartCluster The start cluster number
156 inline void TFatDirEntry::SetStartCluster(TInt aStartCluster)
158 pDir->iStartClusterLo=(TUint16)(aStartCluster);
159 pDir->iStartClusterHi=(TUint16)(aStartCluster >> 16);
162 Set the size of the file or directory refered to by the entry
164 @param aFileSize Size of the file
166 inline void TFatDirEntry::SetSize(TUint32 aFileSize)
167 {pDir->iSize=aFileSize;}
169 Set the directory entry as erased
171 inline void TFatDirEntry::SetErased()
172 {iData[0]=KEntryErasedMarker;}
174 Set the current entry to refer to the current directory
176 inline void TFatDirEntry::SetCurrentDirectory()
179 Mem::Fill(&iData[1],KFatDirNameSize-1,' ');
182 Set the current entry to refer to the parent directory
184 inline void TFatDirEntry::SetParentDirectory()
186 iData[0]='.';iData[1]='.';
187 Mem::Fill(&iData[2],KFatDirNameSize-2,' ');
190 Set the current entry to be the end of directory marker
192 inline void TFatDirEntry::SetEndOfDirectory()
193 {Mem::FillZ(&iData[0],KFatDirNameSize);}
196 Get 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 TUint TFatDirEntry::RuggedFatEntryId() const
201 return pDir->iReserved2;
205 Set VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries
206 Uses 1 byte from "Last Access Date" field, offset 19. Hack.
208 void TFatDirEntry::SetRuggedFatEntryId(TUint16 aId)
210 pDir->iReserved2 = aId;
215 @return True if the entry is the start of a long name set of entries
217 inline TBool TFatDirEntry::IsLongNameStart() const
218 {return (TBool)((iData[0]&0x40) != 0);}
220 @return True is the Entry is a VFat entry
222 inline TBool TFatDirEntry::IsVFatEntry() const
223 {return (TBool)(Attributes()==KVFatEntryAttribute && IsEndOfDirectory()==EFalse);}
225 @return The number of following VFat entries
227 inline TInt TFatDirEntry::NumFollowing() const
228 {return (iData[0]&0x3F);}
231 inline TUint8 TFatDirEntry::CheckSum() const
233 ASSERT(IsVFatEntry());
240 @return ETrue if the Directory entry contains garbage data
242 inline TBool TFatDirEntry::IsGarbage() const
244 return (iData[0]==0xFF);
249 #endif //FAT_DIR_ENTRY_INL