os/kernelhwsrv/userlibandfileserver/fileserver/sfat/fat_dir_entry.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32\sfat\inc\fat_dir_entry.inl
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
 @internalTechnology
sl@0
    21
*/
sl@0
    22
sl@0
    23
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    24
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    25
//!!
sl@0
    26
//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
sl@0
    27
//!!
sl@0
    28
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    29
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    30
sl@0
    31
sl@0
    32
#if !defined(FAT_DIR_ENTRY_INL)
sl@0
    33
#define FAT_DIR_ENTRY_INL
sl@0
    34
sl@0
    35
//-------------------------------------------------------------------------------------------------------------------
sl@0
    36
sl@0
    37
sl@0
    38
/**
sl@0
    39
Defined cast of Fat directory entry data read to structure allowing access to data
sl@0
    40
*/
sl@0
    41
#define pDir ((SFatDirEntry*)&iData[0])
sl@0
    42
sl@0
    43
sl@0
    44
inline TFatDirEntry::TFatDirEntry() 
sl@0
    45
    {
sl@0
    46
    InitZ();
sl@0
    47
    }       
sl@0
    48
sl@0
    49
/** zero-fill the entry contents  */
sl@0
    50
inline void TFatDirEntry::InitZ() 
sl@0
    51
    {
sl@0
    52
    Mem::FillZ(iData, KSizeOfFatDirEntry);
sl@0
    53
    }
sl@0
    54
sl@0
    55
/**
sl@0
    56
Return the Dos name of a directory entry
sl@0
    57
sl@0
    58
@return A descriptor containing the Dos name of a directory entry
sl@0
    59
*/
sl@0
    60
inline const TPtrC8 TFatDirEntry::Name() const
sl@0
    61
    {return TPtrC8((TUint8*)&(pDir->iName),KFatDirNameSize);}
sl@0
    62
/**
sl@0
    63
@return The attributes for the Directory entry
sl@0
    64
*/
sl@0
    65
inline TInt TFatDirEntry::Attributes() const
sl@0
    66
    {return pDir->iAttributes;}
sl@0
    67
/**
sl@0
    68
@param aOffset This offset will be subtracted from the returned time.
sl@0
    69
@return Time of file modification
sl@0
    70
*/
sl@0
    71
inline TTime TFatDirEntry::Time(TTimeIntervalSeconds aOffset) const
sl@0
    72
    {
sl@0
    73
    TTime time=DosTimeToTTime(pDir->iTime,pDir->iDate);
sl@0
    74
    return time-=aOffset;
sl@0
    75
    }
sl@0
    76
/**
sl@0
    77
@return The Start cluster for the file or directory for this entry 
sl@0
    78
*/
sl@0
    79
inline TInt TFatDirEntry::StartCluster() const      
sl@0
    80
    {
sl@0
    81
    const TUint16 KStClustMaskHi = 0x0FFF;  
sl@0
    82
    return ((pDir->iStartClusterHi & KStClustMaskHi) << 16) | pDir->iStartClusterLo;
sl@0
    83
    }
sl@0
    84
sl@0
    85
/**
sl@0
    86
@return The size of file or directory for this entry 
sl@0
    87
*/
sl@0
    88
inline TUint32 TFatDirEntry::Size() const
sl@0
    89
    {return pDir->iSize;}
sl@0
    90
/**
sl@0
    91
@return True if the entry is erased
sl@0
    92
*/
sl@0
    93
inline TBool TFatDirEntry::IsErased() const
sl@0
    94
    {return (TBool)(iData[0]==KEntryErasedMarker);}
sl@0
    95
/**
sl@0
    96
@return True if the entry refers to the current directory
sl@0
    97
*/
sl@0
    98
inline TBool TFatDirEntry::IsCurrentDirectory() const
sl@0
    99
    {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KBlankSpace);}
sl@0
   100
/**
sl@0
   101
@return True if the Entry refers to the parent directory
sl@0
   102
*/
sl@0
   103
inline TBool TFatDirEntry::IsParentDirectory() const
sl@0
   104
    {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KDotEntryByte);}
sl@0
   105
/**
sl@0
   106
@return True if end of directory
sl@0
   107
*/
sl@0
   108
inline TBool TFatDirEntry::IsEndOfDirectory() const
sl@0
   109
    {return (TBool)(iData[0]==0x00);}
sl@0
   110
/**
sl@0
   111
Set the Dos name of a directory entry
sl@0
   112
sl@0
   113
@param aDes A descriptor containg the name
sl@0
   114
*/
sl@0
   115
inline void TFatDirEntry::SetName(const TDesC8& aDes)
sl@0
   116
    {
sl@0
   117
    __ASSERT_DEBUG(aDes.Length()<=KFatDirNameSize,Fault(EFatBadDirEntryParameter));
sl@0
   118
    TPtr8 name(pDir->iName,KFatDirNameSize);
sl@0
   119
    name=aDes;
sl@0
   120
    }
sl@0
   121
/**
sl@0
   122
Set the file or directory attributes for this entry
sl@0
   123
sl@0
   124
@param anAtts The file or directory attributes
sl@0
   125
*/
sl@0
   126
inline void TFatDirEntry::SetAttributes(TInt anAtts)
sl@0
   127
    {
sl@0
   128
    __ASSERT_DEBUG(!(anAtts&~KMaxTUint8),Fault(EFatBadDirEntryParameter));
sl@0
   129
    pDir->iAttributes=(TUint8)anAtts;
sl@0
   130
    }
sl@0
   131
/**
sl@0
   132
Set the modification time and date of the directory entry
sl@0
   133
sl@0
   134
@param aTime Modification time of the file or directory
sl@0
   135
@aOffset aOffset This offset will be added to the time. 
sl@0
   136
*/
sl@0
   137
inline void TFatDirEntry::SetTime(TTime aTime, TTimeIntervalSeconds aOffset)
sl@0
   138
    {
sl@0
   139
    aTime+=aOffset;
sl@0
   140
    pDir->iTime=(TUint16)DosTimeFromTTime(aTime);
sl@0
   141
    pDir->iDate=(TUint16)DosDateFromTTime(aTime);
sl@0
   142
    }
sl@0
   143
sl@0
   144
inline void TFatDirEntry::SetCreateTime(TTime aTime, TTimeIntervalSeconds aOffset)
sl@0
   145
    {
sl@0
   146
    aTime+=aOffset;
sl@0
   147
    pDir->iTimeC=(TUint16)DosTimeFromTTime(aTime);
sl@0
   148
    pDir->iDateC=(TUint16)DosDateFromTTime(aTime);
sl@0
   149
    }
sl@0
   150
sl@0
   151
/**
sl@0
   152
Set the start cluster number of the file or directory refered to by the entry
sl@0
   153
sl@0
   154
@param aStartCluster The start cluster number
sl@0
   155
*/
sl@0
   156
inline void TFatDirEntry::SetStartCluster(TInt aStartCluster)
sl@0
   157
    {
sl@0
   158
    pDir->iStartClusterLo=(TUint16)(aStartCluster);
sl@0
   159
    pDir->iStartClusterHi=(TUint16)(aStartCluster >> 16);
sl@0
   160
    }
sl@0
   161
/**
sl@0
   162
Set the size of the file or directory refered to by the entry
sl@0
   163
sl@0
   164
@param aFileSize Size of the file
sl@0
   165
*/
sl@0
   166
inline void TFatDirEntry::SetSize(TUint32 aFileSize)
sl@0
   167
    {pDir->iSize=aFileSize;}
sl@0
   168
/**
sl@0
   169
Set the directory entry as erased
sl@0
   170
*/
sl@0
   171
inline void TFatDirEntry::SetErased()
sl@0
   172
    {iData[0]=KEntryErasedMarker;}
sl@0
   173
/**
sl@0
   174
Set the current entry to refer to the current directory
sl@0
   175
*/
sl@0
   176
inline void TFatDirEntry::SetCurrentDirectory()
sl@0
   177
    {
sl@0
   178
    iData[0]='.';
sl@0
   179
    Mem::Fill(&iData[1],KFatDirNameSize-1,' ');
sl@0
   180
    }
sl@0
   181
/**
sl@0
   182
Set the current entry to refer to the parent directory
sl@0
   183
*/
sl@0
   184
inline void TFatDirEntry::SetParentDirectory()
sl@0
   185
    {
sl@0
   186
    iData[0]='.';iData[1]='.';
sl@0
   187
    Mem::Fill(&iData[2],KFatDirNameSize-2,' ');
sl@0
   188
    }
sl@0
   189
/**
sl@0
   190
Set the current entry to be the end of directory marker
sl@0
   191
*/
sl@0
   192
inline void TFatDirEntry::SetEndOfDirectory()
sl@0
   193
    {Mem::FillZ(&iData[0],KFatDirNameSize);}
sl@0
   194
sl@0
   195
/**
sl@0
   196
    Get VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries
sl@0
   197
    Uses 1 byte from "Last Access Date" field, offset 19. Hack.
sl@0
   198
*/
sl@0
   199
TUint TFatDirEntry::RuggedFatEntryId() const
sl@0
   200
    {
sl@0
   201
    return pDir->iReserved2;
sl@0
   202
    }
sl@0
   203
sl@0
   204
/**
sl@0
   205
    Set VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries
sl@0
   206
    Uses 1 byte from "Last Access Date" field, offset 19. Hack.
sl@0
   207
*/
sl@0
   208
void  TFatDirEntry::SetRuggedFatEntryId(TUint16 aId) 
sl@0
   209
    {
sl@0
   210
    pDir->iReserved2 = aId;
sl@0
   211
    }
sl@0
   212
sl@0
   213
sl@0
   214
/**
sl@0
   215
@return True if the entry is the start of a long name set of entries
sl@0
   216
*/
sl@0
   217
inline TBool TFatDirEntry::IsLongNameStart() const
sl@0
   218
    {return (TBool)((iData[0]&0x40) != 0);}
sl@0
   219
/**
sl@0
   220
@return True is the Entry is a VFat entry
sl@0
   221
*/
sl@0
   222
inline TBool TFatDirEntry::IsVFatEntry() const
sl@0
   223
    {return (TBool)(Attributes()==KVFatEntryAttribute && IsEndOfDirectory()==EFalse);}
sl@0
   224
/**
sl@0
   225
@return The number of following VFat entries
sl@0
   226
*/
sl@0
   227
inline TInt TFatDirEntry::NumFollowing() const
sl@0
   228
    {return (iData[0]&0x3F);}
sl@0
   229
sl@0
   230
sl@0
   231
inline TUint8 TFatDirEntry::CheckSum() const
sl@0
   232
    {
sl@0
   233
        ASSERT(IsVFatEntry());
sl@0
   234
        return iData[13];
sl@0
   235
    }
sl@0
   236
sl@0
   237
sl@0
   238
sl@0
   239
/**
sl@0
   240
@return  ETrue if the Directory entry contains garbage data
sl@0
   241
*/
sl@0
   242
inline TBool TFatDirEntry::IsGarbage() const
sl@0
   243
    {
sl@0
   244
    return (iData[0]==0xFF);
sl@0
   245
    }
sl@0
   246
sl@0
   247
sl@0
   248
sl@0
   249
#endif //FAT_DIR_ENTRY_INL
sl@0
   250
sl@0
   251
sl@0
   252
sl@0
   253
sl@0
   254
sl@0
   255
sl@0
   256
sl@0
   257
sl@0
   258
sl@0
   259
sl@0
   260
sl@0
   261
sl@0
   262
sl@0
   263