os/kernelhwsrv/kerneltest/f32test/fileutils/src/fat_utils.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1996-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
// @file
sl@0
    15
// various FAT test utilities 
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
sl@0
    20
#include "fat_utils.h"
sl@0
    21
using namespace Fat_Test_Utils;
sl@0
    22
sl@0
    23
sl@0
    24
sl@0
    25
//-------------------------------------------------------------------------------------------------------------------
sl@0
    26
sl@0
    27
//-- define this macro if it is necessarily to exclude all stuff that uses RFs, consoles etc.
sl@0
    28
//-- may be useful if this code is used for file server extensions. mmp file is a good place to define this macro.
sl@0
    29
#ifndef FAT_UTILS_LEAN_AND_MEAN
sl@0
    30
sl@0
    31
#include <e32cons.h>
sl@0
    32
#include <e32math.h>
sl@0
    33
sl@0
    34
//-------------------------------------------------------------------------------------------------------------------
sl@0
    35
sl@0
    36
/**
sl@0
    37
    Format FAT volume
sl@0
    38
    
sl@0
    39
    @param  aFs             reference to the FS session
sl@0
    40
    @param  aDrive          drive number
sl@0
    41
    @param  aQuickFormat    if True, a quick format will be performed. otherwise - full
sl@0
    42
    @param  apFmtParams     pointer to the optional format parameters. if NULL, it means tha no options specified
sl@0
    43
    @param  aForceErase     if True, use media force erase.
sl@0
    44
sl@0
    45
    @return system-wide error codes.
sl@0
    46
*/
sl@0
    47
TInt Fat_Test_Utils::FormatFatDrive(RFs &aFs, TInt aDrive, TBool aQuickFormat, const TFatFormatParam* apFmtParams/*=NULL*/, TBool aForceErase /*=EFalse*/)
sl@0
    48
{
sl@0
    49
    TPtrC fmtTypeName = (aQuickFormat ? _L("Quick") : _L("Full"));
sl@0
    50
    DoPrintf(_L("~ Fat_Test_Utils::FormatFatDrive() drv:%d, type:%S\n"),aDrive, &fmtTypeName);
sl@0
    51
   
sl@0
    52
    ASSERT(aDrive >= EDriveA && aDrive <= EDriveZ);
sl@0
    53
    
sl@0
    54
    RFormat format;
sl@0
    55
    TUint   fmtMode=0;
sl@0
    56
    TInt    fmtCnt=0;
sl@0
    57
    TInt    prevCnt;
sl@0
    58
    TInt    nRes;
sl@0
    59
sl@0
    60
    if(aQuickFormat) 
sl@0
    61
        fmtMode |= EQuickFormat;
sl@0
    62
sl@0
    63
    if(aForceErase)
sl@0
    64
        fmtMode |= EForceErase;
sl@0
    65
sl@0
    66
    TBuf<10> drvName;
sl@0
    67
    drvName.Format(_L("%C:"),'A'+aDrive);
sl@0
    68
sl@0
    69
    if(!apFmtParams)
sl@0
    70
    {//-- no format parameters specified
sl@0
    71
        //DoPrintf(_L("~ Format parameters - not specified\n"));
sl@0
    72
        nRes = format.Open(aFs, drvName, fmtMode, fmtCnt);
sl@0
    73
        if(nRes!=KErrNone)
sl@0
    74
            goto Fail;
sl@0
    75
    }
sl@0
    76
    else
sl@0
    77
    {//-- some extra parameters specified, use special format
sl@0
    78
        fmtMode |= ESpecialFormat;
sl@0
    79
        TLDFormatInfo formatInfo;
sl@0
    80
sl@0
    81
        TBuf<100> buf;
sl@0
    82
        buf.Copy(_L("~ Format parameters: "));
sl@0
    83
        
sl@0
    84
        if(apFmtParams->iFatType)
sl@0
    85
        {//-- FAT type is specified
sl@0
    86
            buf.AppendFormat(_L("FAT%d"), apFmtParams->iFatType);
sl@0
    87
            formatInfo.iFATBits = (TLDFormatInfo::TFATBits)apFmtParams->iFatType;
sl@0
    88
        }
sl@0
    89
sl@0
    90
        const TUint16 spc = (TUint16)apFmtParams->iSecPerCluster;
sl@0
    91
        if(spc)
sl@0
    92
        {//-- sectors per cluster value is specified
sl@0
    93
            buf.AppendFormat(_L(", spc:%d"), spc);
sl@0
    94
            formatInfo.iSectorsPerCluster = spc;
sl@0
    95
        }
sl@0
    96
sl@0
    97
        const TUint16 rsvdSec = (TUint16)apFmtParams->iReservedSectors;
sl@0
    98
        if(rsvdSec)
sl@0
    99
        {//-- reserved sectors numer is specified
sl@0
   100
            buf.AppendFormat(_L(", rsvdSec:%d"), rsvdSec);
sl@0
   101
            formatInfo.iReservedSectors = rsvdSec;
sl@0
   102
        }
sl@0
   103
        
sl@0
   104
        buf.Append(_L("\n"));
sl@0
   105
        DoPrintf(buf);
sl@0
   106
        
sl@0
   107
        TSpecialFormatInfoBuf formatInfoBuf(formatInfo);
sl@0
   108
        nRes = format.Open(aFs, drvName, fmtMode, fmtCnt, formatInfoBuf);
sl@0
   109
        if(nRes!=KErrNone)
sl@0
   110
            goto Fail;
sl@0
   111
sl@0
   112
    }
sl@0
   113
sl@0
   114
    //-- do format steps
sl@0
   115
    prevCnt=fmtCnt;
sl@0
   116
    while(fmtCnt)
sl@0
   117
    {
sl@0
   118
        nRes = format.Next(fmtCnt);
sl@0
   119
        if(nRes!=KErrNone)
sl@0
   120
            goto Fail;
sl@0
   121
sl@0
   122
        if(fmtCnt != prevCnt)
sl@0
   123
        {
sl@0
   124
            DoPrintf(_L("."));
sl@0
   125
            prevCnt = fmtCnt;
sl@0
   126
        }
sl@0
   127
    }
sl@0
   128
sl@0
   129
    //-- formatting has finished
sl@0
   130
    DoPrintf(_L("\n"));
sl@0
   131
    format.Close();
sl@0
   132
    return KErrNone;
sl@0
   133
sl@0
   134
   Fail:
sl@0
   135
    format.Close();
sl@0
   136
    DoPrintf(_L("~ Fat_Test_Utils::FormatFatDrive() failed! code:%d\n"), nRes);
sl@0
   137
sl@0
   138
    return nRes;
sl@0
   139
}
sl@0
   140
sl@0
   141
//-------------------------------------------------------------------------------------------------------------------
sl@0
   142
sl@0
   143
/**
sl@0
   144
    Read FAT FSInfo sector via RRawDisk interface.
sl@0
   145
    @param  aFs         reference to the FS session
sl@0
   146
    @param  aDrive      drive number
sl@0
   147
    @param  aMediaPos   media position (0 for the main boot sector)
sl@0
   148
    @param  aFsInfo     where to read data
sl@0
   149
sl@0
   150
    @return standard error codes
sl@0
   151
*/
sl@0
   152
TInt Fat_Test_Utils::ReadFSInfoSector(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TFSInfo& aFsInfo)
sl@0
   153
{
sl@0
   154
    DoPrintf(_L("~ Fat_Test_Utils::ReadFSInfoSector() drv:%d, pos:0x%x\n"),aDrive, (TUint32)aMediaPos);   
sl@0
   155
sl@0
   156
    TInt nRes = KErrNone;
sl@0
   157
    
sl@0
   158
    TBuf8<KSizeOfFSInfo> fsInfoSecBuf(KSizeOfFSInfo);
sl@0
   159
    TRAP(nRes, DoMediaRawReadL(aFs, aDrive, aMediaPos, fsInfoSecBuf.Size(), fsInfoSecBuf));
sl@0
   160
sl@0
   161
    if(nRes == KErrNone)
sl@0
   162
    {//-- take FSInfo data from the buffer
sl@0
   163
        aFsInfo.Internalize(fsInfoSecBuf);
sl@0
   164
    }
sl@0
   165
sl@0
   166
    return nRes;
sl@0
   167
}
sl@0
   168
sl@0
   169
//-------------------------------------------------------------------------------------------------------------------
sl@0
   170
sl@0
   171
/**
sl@0
   172
    Write FAT FSInfo sector via RRawDisk interface.
sl@0
   173
    @param  aFs         reference to the FS session
sl@0
   174
    @param  aDrive      drive number
sl@0
   175
    @param  aMediaPos   media position (0 for the main boot sector)
sl@0
   176
    @param  aFsInfo     data to write
sl@0
   177
sl@0
   178
    @return standard error codes
sl@0
   179
*/
sl@0
   180
TInt Fat_Test_Utils::WriteFSInfoSector(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TFSInfo& aFsInfo)
sl@0
   181
{
sl@0
   182
    DoPrintf(_L("~ Fat_Test_Utils::WriteFSInfoSector() drv:%d, pos:0x%x\n"),aDrive, (TUint32)aMediaPos);   
sl@0
   183
    
sl@0
   184
    TInt nRes = KErrNone;
sl@0
   185
    TBuf8<KSizeOfFSInfo> fsInfoSecBuf;
sl@0
   186
sl@0
   187
    //-- put data to the sector buffer
sl@0
   188
    aFsInfo.Externalize(fsInfoSecBuf);
sl@0
   189
  
sl@0
   190
    TRAP(nRes, DoMediaRawWriteL(aFs, aDrive, aMediaPos, fsInfoSecBuf))
sl@0
   191
sl@0
   192
    return nRes;
sl@0
   193
}
sl@0
   194
sl@0
   195
//-------------------------------------------------------------------------------------------------------------------
sl@0
   196
sl@0
   197
/**
sl@0
   198
    Read FAT boot sector via RRawDisk interface.
sl@0
   199
    @param  aFs         reference to the FS session
sl@0
   200
    @param  aDrive      drive number
sl@0
   201
    @param  aMediaPos   media position (0 for the main boot sector)
sl@0
   202
    @param  aBootSector where to read data
sl@0
   203
sl@0
   204
    @return standard error codes
sl@0
   205
*/
sl@0
   206
TInt  Fat_Test_Utils::ReadBootSector(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TFatBootSector& aBootSector)
sl@0
   207
{
sl@0
   208
    DoPrintf(_L("~ Fat_Test_Utils::ReadBootSector() drv:%d, pos:0x%x\n"),aDrive, (TUint32)aMediaPos);   
sl@0
   209
    
sl@0
   210
    TInt nRes = KErrNone;
sl@0
   211
    TBuf8<KSizeOfFatBootSector> bootSecBuf(KSizeOfFatBootSector);
sl@0
   212
sl@0
   213
    TRAP(nRes, DoMediaRawReadL(aFs, aDrive, aMediaPos, bootSecBuf.Size(), bootSecBuf));
sl@0
   214
sl@0
   215
    if(nRes==KErrNone)
sl@0
   216
    {//-- initialise TFatBootSector object
sl@0
   217
        aBootSector.Internalize(bootSecBuf);
sl@0
   218
    }
sl@0
   219
sl@0
   220
    return nRes;
sl@0
   221
}
sl@0
   222
sl@0
   223
//-------------------------------------------------------------------------------------------------------------------
sl@0
   224
sl@0
   225
/**
sl@0
   226
    Write FAT boot sector via RRawDisk interface.
sl@0
   227
    @param  aFs         reference to the FS session
sl@0
   228
    @param  aDrive      drive number
sl@0
   229
    @param  aMediaPos   media position (0 for the main boot sector)
sl@0
   230
    @param  aBootSector data to write
sl@0
   231
sl@0
   232
    @return standard error codes
sl@0
   233
*/
sl@0
   234
TInt  Fat_Test_Utils::WriteBootSector(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TFatBootSector& aBootSector)
sl@0
   235
{
sl@0
   236
    DoPrintf(_L("~ Fat_Test_Utils::WriteBootSector() drv:%d, pos:0x%x\n"),aDrive, (TUint32)aMediaPos);   
sl@0
   237
    
sl@0
   238
    TBuf8<KDefaultSectorSize> bootSecBuf(KDefaultSectorSize);
sl@0
   239
    
sl@0
   240
    //-- externalize boot sector to the data buffer
sl@0
   241
    bootSecBuf.FillZ();
sl@0
   242
    aBootSector.Externalize(bootSecBuf); 
sl@0
   243
    
sl@0
   244
    //-- put a boot sector signature to the last 2 bytes
sl@0
   245
    bootSecBuf[KDefaultSectorSize-2] = 0x55;
sl@0
   246
    bootSecBuf[KDefaultSectorSize-1] = 0xaa;
sl@0
   247
sl@0
   248
    //-- write boot sector data to the media
sl@0
   249
    TInt nRes=KErrNone;
sl@0
   250
    TRAP(nRes, DoMediaRawWriteL(aFs, aDrive, aMediaPos, bootSecBuf));
sl@0
   251
    
sl@0
   252
    return nRes;
sl@0
   253
}
sl@0
   254
//-------------------------------------------------------------------------------------------------------------------
sl@0
   255
/** 
sl@0
   256
    Obtain FAT type for the given drive 
sl@0
   257
sl@0
   258
    @return TFatType enum values. if aDrive has not FAT FS, EInvalid value is returned
sl@0
   259
*/
sl@0
   260
TFatType Fat_Test_Utils::GetFatType(RFs &aFs, TInt aDrive)
sl@0
   261
{
sl@0
   262
    if(Is_Fat16(aFs, aDrive))
sl@0
   263
        return EFat16;
sl@0
   264
    else if(Is_Fat32(aFs, aDrive))
sl@0
   265
        return EFat32;
sl@0
   266
    else if(Is_Fat12(aFs, aDrive))
sl@0
   267
        return EFat12;
sl@0
   268
sl@0
   269
    return EInvalid;
sl@0
   270
}
sl@0
   271
sl@0
   272
//-------------------------------------------------------------------------------------------------------------------
sl@0
   273
sl@0
   274
#endif //FAT_UTILS_LEAN_AND_MEAN
sl@0
   275
sl@0
   276
sl@0
   277
sl@0
   278
sl@0
   279
TFatFormatParam::TFatFormatParam()
sl@0
   280
{
sl@0
   281
    iFatType = EInvalid;
sl@0
   282
    iSecPerCluster = 0;
sl@0
   283
    iReservedSectors = 0;
sl@0
   284
}
sl@0
   285
        
sl@0
   286
//-------------------------------------------------------------------------------------------------------------------
sl@0
   287
sl@0
   288
TFatBootSector::TFatBootSector()
sl@0
   289
{
sl@0
   290
    Initialise();
sl@0
   291
}
sl@0
   292
sl@0
   293
/** initialises the boot sector data */
sl@0
   294
void TFatBootSector::Initialise()
sl@0
   295
{
sl@0
   296
    Mem::FillZ(this, sizeof(TFatBootSector));
sl@0
   297
}
sl@0
   298
sl@0
   299
TBool TFatBootSector::operator==(const TFatBootSector& aRhs)
sl@0
   300
{
sl@0
   301
    ASSERT(&aRhs != this);
sl@0
   302
    if(&aRhs == this)
sl@0
   303
        return ETrue; //-- comparing with itself
sl@0
   304
sl@0
   305
    return  (Mem::Compare((TUint8*)this, sizeof(TFatBootSector), (TUint8*)&aRhs, sizeof(TFatBootSector)) == 0);
sl@0
   306
}
sl@0
   307
sl@0
   308
sl@0
   309
/**
sl@0
   310
    @return ETrue if the boot sector contents seems to be valid
sl@0
   311
*/
sl@0
   312
TBool TFatBootSector::IsValid() const
sl@0
   313
{
sl@0
   314
    const TFatType fatType = FatType(); //-- it will check SectorsPerCluster etc.
sl@0
   315
sl@0
   316
    if(fatType == EInvalid || ReservedSectors() < 1 || NumberOfFats() < 1)
sl@0
   317
        goto Invalid;
sl@0
   318
        
sl@0
   319
    if(fatType == EFat32)
sl@0
   320
    {
sl@0
   321
        if(VersionNumber()!= 0 || FatSectors()!=0 || FatSectors32()<1 || RootClusterNum()<(TUint32)KFatFirstSearchCluser ||
sl@0
   322
           TotalSectors()!=0 || HugeSectors() <5 || RootDirEntries() !=0)
sl@0
   323
        {
sl@0
   324
            goto Invalid; //-- these values are not compliant with FAT specs
sl@0
   325
        }
sl@0
   326
    }
sl@0
   327
    else //-- FAT12/16
sl@0
   328
    {
sl@0
   329
        if(TotalSectors() >0 && HugeSectors() >0 )
sl@0
   330
            goto Invalid; //-- values clash
sl@0
   331
sl@0
   332
        const TUint32 totSectors = Max(TotalSectors(), HugeSectors());
sl@0
   333
        const TUint32 rootDirStartSec =  ReservedSectors() + FatSectors()*NumberOfFats(); //-- root directory start sector
sl@0
   334
sl@0
   335
        if(FatSectors() < 1 || rootDirStartSec < 3 || RootDirEntries() < 1 || totSectors < 5)
sl@0
   336
            goto Invalid; //-- these values are not compliant with FAT specs
sl@0
   337
    }
sl@0
   338
sl@0
   339
    return ETrue;
sl@0
   340
  
sl@0
   341
  Invalid:
sl@0
   342
    DoPrintf(_L("~ TFatBootSector::IsValid() failed!\n"));
sl@0
   343
sl@0
   344
    return EFalse;
sl@0
   345
}
sl@0
   346
sl@0
   347
//-------------------------------------------------------------------------------------------------------------------
sl@0
   348
sl@0
   349
/**
sl@0
   350
    Initialize boot sector object from the given bufer. Does not validate the data.
sl@0
   351
    @param  aBuf buffer with data.
sl@0
   352
*/
sl@0
   353
void TFatBootSector::Internalize(const TDesC8& aBuf)
sl@0
   354
{
sl@0
   355
    ASSERT(aBuf.Size() >= KSizeOfFatBootSector);
sl@0
   356
sl@0
   357
    Initialise();
sl@0
   358
sl@0
   359
    TInt pos=0;
sl@0
   360
sl@0
   361
    Mem::Copy(&iJumpInstruction, &aBuf[pos],3);     pos+=3; // 0    TUint8 iJumpInstruction[3]
sl@0
   362
    Mem::Copy(&iVendorId,&aBuf[pos],KVendorIdSize); pos+=KVendorIdSize; // 3    TUint8 iVendorId[KVendorIdSize]
sl@0
   363
    Mem::Copy(&iBytesPerSector,&aBuf[pos],2);       pos+=2; // 11   TUint16 iBytesPerSector
sl@0
   364
    Mem::Copy(&iSectorsPerCluster,&aBuf[pos],1);    pos+=1; // 13   TUint8 iSectorsPerCluster   
sl@0
   365
    Mem::Copy(&iReservedSectors,&aBuf[pos],2);      pos+=2; // 14   TUint16 iReservedSectors
sl@0
   366
    Mem::Copy(&iNumberOfFats,&aBuf[pos],1);         pos+=1; // 16   TUint8 iNumberOfFats
sl@0
   367
    Mem::Copy(&iRootDirEntries,&aBuf[pos],2);       pos+=2; // 17   TUint16 iRootDirEntries
sl@0
   368
    Mem::Copy(&iTotalSectors,&aBuf[pos],2);         pos+=2; // 19   TUint16 iTotalSectors
sl@0
   369
    Mem::Copy(&iMediaDescriptor,&aBuf[pos],1);      pos+=1; // 21   TUint8 iMediaDescriptor
sl@0
   370
    Mem::Copy(&iFatSectors,&aBuf[pos],2);           pos+=2; // 22   TUint16 iFatSectors
sl@0
   371
    Mem::Copy(&iSectorsPerTrack,&aBuf[pos],2);      pos+=2; // 24   TUint16 iSectorsPerTrack
sl@0
   372
    Mem::Copy(&iNumberOfHeads,&aBuf[pos],2);        pos+=2; // 26   TUint16 iNumberOfHeads
sl@0
   373
    Mem::Copy(&iHiddenSectors,&aBuf[pos],4);        pos+=4; // 28   TUint32 iHiddenSectors
sl@0
   374
    Mem::Copy(&iHugeSectors,&aBuf[pos],4);          pos+=4; // 32   TUint32 iHugeSectors
sl@0
   375
sl@0
   376
    if(RootDirEntries() == 0) //-- we have FAT32 volume
sl@0
   377
    {
sl@0
   378
        Mem::Copy(&iFatSectors32, &aBuf[pos],4);    pos+=4; // 36 TUint32 iFatSectors32     
sl@0
   379
        Mem::Copy(&iFATFlags, &aBuf[pos],2);        pos+=2; // 40 TUint16 iFATFlags
sl@0
   380
        Mem::Copy(&iVersionNumber, &aBuf[pos],2);   pos+=2; // 42 TUint16 iVersionNumber
sl@0
   381
        Mem::Copy(&iRootClusterNum, &aBuf[pos],4);  pos+=4; // 44 TUint32 iRootClusterNum
sl@0
   382
        Mem::Copy(&iFSInfoSectorNum, &aBuf[pos],2); pos+=2; // 48 TUint16 iFSInfoSectorNum
sl@0
   383
        Mem::Copy(&iBkBootRecSector, &aBuf[pos],2);         // 50 TUint16 iBkBootRecSector
sl@0
   384
        pos+=(2+12);    //extra 12 for the reserved bytes   
sl@0
   385
    }
sl@0
   386
sl@0
   387
    Mem::Copy(&iPhysicalDriveNumber,&aBuf[pos],1);  pos+=1;// 36|64 TUint8 iPhysicalDriveNumber
sl@0
   388
    Mem::Copy(&iReserved,&aBuf[pos],1);             pos+=1;// 37|65 TUint8 iReserved
sl@0
   389
    Mem::Copy(&iExtendedBootSignature,&aBuf[pos],1);pos+=1;// 38|66 TUint8 iExtendedBootSignature
sl@0
   390
    Mem::Copy(&iUniqueID,&aBuf[pos],4);             pos+=4;// 39|67 TUint32 iUniqueID
sl@0
   391
    Mem::Copy(&iVolumeLabel,&aBuf[pos],KVolumeLabelSize);  // 43|71 TUint8 iVolumeLabel[KVolumeLabelSize]
sl@0
   392
    pos+=KVolumeLabelSize;
sl@0
   393
sl@0
   394
    // 54|82    TUint8 iFileSysType[KFileSysTypeSize]
sl@0
   395
    ASSERT(aBuf.Size() >= pos+KFileSysTypeSize);
sl@0
   396
    Mem::Copy(&iFileSysType,&aBuf[pos],KFileSysTypeSize);
sl@0
   397
}
sl@0
   398
sl@0
   399
//-------------------------------------------------------------------------------------------------------------------
sl@0
   400
sl@0
   401
/**
sl@0
   402
    Externalize boot sector object to the given data buffer.
sl@0
   403
    @param  aBuf buffer to externalize.
sl@0
   404
*/
sl@0
   405
void TFatBootSector::Externalize(TDes8& aBuf) const
sl@0
   406
{
sl@0
   407
    ASSERT(aBuf.MaxSize() >= KSizeOfFatBootSector);
sl@0
   408
sl@0
   409
    if(aBuf.Size() < KSizeOfFatBootSector)
sl@0
   410
        aBuf.SetLength(KSizeOfFatBootSector);
sl@0
   411
    
sl@0
   412
    TInt pos=0;
sl@0
   413
sl@0
   414
    Mem::Copy(&aBuf[pos],&iJumpInstruction,3);      pos+=3;
sl@0
   415
    Mem::Copy(&aBuf[pos],&iVendorId,KVendorIdSize); pos+=8;
sl@0
   416
    Mem::Copy(&aBuf[pos],&iBytesPerSector,2);       pos+=2;
sl@0
   417
    Mem::Copy(&aBuf[pos],&iSectorsPerCluster,1);    pos+=1;
sl@0
   418
    Mem::Copy(&aBuf[pos],&iReservedSectors,2);      pos+=2;
sl@0
   419
    Mem::Copy(&aBuf[pos],&iNumberOfFats,1);         pos+=1;
sl@0
   420
    Mem::Copy(&aBuf[pos],&iRootDirEntries,2);       pos+=2;
sl@0
   421
    Mem::Copy(&aBuf[pos],&iTotalSectors,2);         pos+=2;
sl@0
   422
    Mem::Copy(&aBuf[pos],&iMediaDescriptor,1);      pos+=1;
sl@0
   423
    Mem::Copy(&aBuf[pos],&iFatSectors,2);           pos+=2;
sl@0
   424
    Mem::Copy(&aBuf[pos],&iSectorsPerTrack,2);      pos+=2;
sl@0
   425
    Mem::Copy(&aBuf[pos],&iNumberOfHeads,2);        pos+=2;
sl@0
   426
    Mem::Copy(&aBuf[pos],&iHiddenSectors,4);        pos+=4;
sl@0
   427
    Mem::Copy(&aBuf[pos],&iHugeSectors,4);          pos+=4;
sl@0
   428
sl@0
   429
    if(iFatSectors == 0)    
sl@0
   430
        {
sl@0
   431
        Mem::Copy(&aBuf[pos], &iFatSectors32,4);    pos+=4;
sl@0
   432
        Mem::Copy(&aBuf[pos], &iFATFlags, 2);       pos+=2;
sl@0
   433
        Mem::Copy(&aBuf[pos], &iVersionNumber, 2);  pos+=2;
sl@0
   434
        Mem::Copy(&aBuf[pos], &iRootClusterNum, 4); pos+=4;
sl@0
   435
        Mem::Copy(&aBuf[pos], &iFSInfoSectorNum, 2);pos+=2;
sl@0
   436
        Mem::Copy(&aBuf[pos], &iBkBootRecSector, 2);pos+=2;
sl@0
   437
sl@0
   438
        //extra 12 for the reserved bytes   
sl@0
   439
        ASSERT(aBuf.Size() >= pos+12);
sl@0
   440
        Mem::FillZ(&aBuf[pos],12);
sl@0
   441
        pos+=12;
sl@0
   442
        }
sl@0
   443
sl@0
   444
    Mem::Copy(&aBuf[pos],&iPhysicalDriveNumber,1);  pos+=1;
sl@0
   445
    Mem::FillZ(&aBuf[pos],1);                       pos+=1;
sl@0
   446
    Mem::Copy(&aBuf[pos],&iExtendedBootSignature,1);pos+=1;
sl@0
   447
    Mem::Copy(&aBuf[pos],&iUniqueID,4);             pos+=4;
sl@0
   448
    
sl@0
   449
    Mem::Copy(&aBuf[pos],&iVolumeLabel,KVolumeLabelSize); 
sl@0
   450
    pos+=KVolumeLabelSize;
sl@0
   451
    
sl@0
   452
    ASSERT(aBuf.MaxSize() >= pos+KFileSysTypeSize);
sl@0
   453
    Mem::Copy(&aBuf[pos],&iFileSysType,KFileSysTypeSize);
sl@0
   454
}
sl@0
   455
sl@0
   456
//-------------------------------------------------------------------------------------------------------------------
sl@0
   457
sl@0
   458
/** replaces all non-printable characters in a buffer with spaces */
sl@0
   459
static void FixDes(TDes& aDes)
sl@0
   460
{
sl@0
   461
    for(TInt i=0; i< aDes.Length(); ++i)
sl@0
   462
    {
sl@0
   463
        TChar ch=aDes[i];
sl@0
   464
        if(!ch.IsPrint())
sl@0
   465
            aDes[i]=' ';    
sl@0
   466
    }
sl@0
   467
}
sl@0
   468
sl@0
   469
/** 
sl@0
   470
    Print out the boot sector info.
sl@0
   471
*/
sl@0
   472
void TFatBootSector::PrintDebugInfo() const
sl@0
   473
{
sl@0
   474
    TBuf<40> buf;
sl@0
   475
    
sl@0
   476
    DoPrintf(_L("======== BootSector info: =======\n"));
sl@0
   477
    
sl@0
   478
    buf.Copy(FileSysType()); FixDes(buf);    
sl@0
   479
    DoPrintf(_L("FAT type:%S\n"),&buf);
sl@0
   480
sl@0
   481
    buf.Copy(VendorId()); FixDes(buf);
sl@0
   482
    DoPrintf(_L("Vendor ID:%S\n"),&buf);
sl@0
   483
sl@0
   484
    DoPrintf(_L("BytesPerSector: %d\n"),BytesPerSector());
sl@0
   485
    DoPrintf(_L("SectorsPerCluster: %d\n"),SectorsPerCluster());
sl@0
   486
    DoPrintf(_L("ReservedSectors: %d\n"),ReservedSectors());
sl@0
   487
    DoPrintf(_L("NumberOfFats: %d\n"),NumberOfFats());
sl@0
   488
    DoPrintf(_L("RootDirEntries: %d\n"),RootDirEntries());
sl@0
   489
    DoPrintf(_L("Total Sectors: %d\n"),TotalSectors());
sl@0
   490
    DoPrintf(_L("MediaDescriptor: 0x%x\n"),MediaDescriptor());
sl@0
   491
    DoPrintf(_L("FatSectors: %d\n"),FatSectors());
sl@0
   492
    DoPrintf(_L("SectorsPerTrack: %d\n"),SectorsPerTrack());
sl@0
   493
    DoPrintf(_L("NumberOfHeads: %d\n"),NumberOfHeads());
sl@0
   494
    DoPrintf(_L("HugeSectors: %d\n"),HugeSectors());
sl@0
   495
    DoPrintf(_L("Fat32 Sectors: %d\n"),FatSectors32());
sl@0
   496
    DoPrintf(_L("Fat32 Flags: %d\n"),FATFlags());
sl@0
   497
    DoPrintf(_L("Fat32 Version Number: %d\n"),VersionNumber());
sl@0
   498
    DoPrintf(_L("Root Cluster Number: %d\n"),RootClusterNum());
sl@0
   499
    DoPrintf(_L("FSInfo Sector Number: %d\n"),FSInfoSectorNum());
sl@0
   500
    DoPrintf(_L("Backup Boot Rec Sector Number: %d\n"),BkBootRecSector());
sl@0
   501
    DoPrintf(_L("PhysicalDriveNumber:%d\n"),PhysicalDriveNumber());
sl@0
   502
    DoPrintf(_L("ExtendedBootSignature: %d\n"),ExtendedBootSignature());
sl@0
   503
    DoPrintf(_L("UniqueID: 0x%x\n"),UniqueID());
sl@0
   504
    
sl@0
   505
    buf.Copy(VolumeLabel()); FixDes(buf);
sl@0
   506
    DoPrintf(_L("VolumeLabel:%S\n"),&buf);
sl@0
   507
    
sl@0
   508
    DoPrintf(_L("=============================\n"));
sl@0
   509
}
sl@0
   510
sl@0
   511
//-------------------------------------------------------------------------------------------------------------------
sl@0
   512
sl@0
   513
sl@0
   514
/**
sl@0
   515
    Determine FAT type according to the information from boot sector, see FAT32 specs.
sl@0
   516
    @return  FAT type. 
sl@0
   517
*/
sl@0
   518
TFatType TFatBootSector::FatType(void) const
sl@0
   519
    {
sl@0
   520
sl@0
   521
    //-- check iBytesPerSector validity; it shall be one of: 512,1024,2048,4096
sl@0
   522
    if(!IsPowerOf2(iBytesPerSector) || iBytesPerSector < 512 ||  iBytesPerSector > 4096)
sl@0
   523
        return EInvalid; //-- invalid iBytesPerSector value
sl@0
   524
sl@0
   525
    //-- check iSectorsPerCluster validity, it shall be one of: 1,2,4,8...128
sl@0
   526
    if(!IsPowerOf2(iSectorsPerCluster) || iSectorsPerCluster > 128)
sl@0
   527
        return EInvalid; //-- invalid iSectorsPerCluster value
sl@0
   528
sl@0
   529
    const TUint32 rootDirSectors = (iRootDirEntries*KSizeOfFatDirEntry + (iBytesPerSector-1)) / iBytesPerSector;
sl@0
   530
    const TUint32 fatSz = iFatSectors ? iFatSectors : iFatSectors32;
sl@0
   531
    const TUint32 totSec = iTotalSectors ? iTotalSectors : iHugeSectors;
sl@0
   532
    const TUint32 dataSec = totSec - (iReservedSectors + (iNumberOfFats * fatSz) + rootDirSectors);
sl@0
   533
    const TUint32 clusterCnt = dataSec / iSectorsPerCluster;
sl@0
   534
sl@0
   535
    //-- magic. see FAT specs for details.
sl@0
   536
    if(clusterCnt < 4085)
sl@0
   537
        return EFat12;
sl@0
   538
    else if(clusterCnt < 65525)
sl@0
   539
        return EFat16;
sl@0
   540
    else
sl@0
   541
        return EFat32;
sl@0
   542
sl@0
   543
    }
sl@0
   544
sl@0
   545
//-------------------------------------------------------------------------------------------------------------------
sl@0
   546
sl@0
   547
/** Returns Sectors in Fat table for 32 bit volume */
sl@0
   548
TUint32 TFatBootSector::FatSectors32() const	
sl@0
   549
{return iFatSectors32;}
sl@0
   550
sl@0
   551
/** Fat flags */
sl@0
   552
TUint16 TFatBootSector::FATFlags() const		
sl@0
   553
{return iFATFlags;}
sl@0
   554
sl@0
   555
/** Version number of the file system */
sl@0
   556
TUint16 TFatBootSector::VersionNumber() const		
sl@0
   557
{return iVersionNumber;}
sl@0
   558
sl@0
   559
/** Cluster number of the root directory */
sl@0
   560
TUint32 TFatBootSector::RootClusterNum() const	
sl@0
   561
{return iRootClusterNum;}
sl@0
   562
sl@0
   563
/** Sector number containing the FSIInfo structure */
sl@0
   564
TUint16 TFatBootSector::FSInfoSectorNum() const
sl@0
   565
{return iFSInfoSectorNum;}
sl@0
   566
sl@0
   567
/** Backup boot sector */
sl@0
   568
TUint16 TFatBootSector::BkBootRecSector() const
sl@0
   569
{return iBkBootRecSector;}
sl@0
   570
sl@0
   571
/** Sets the number of sectors in Fat table for 32 bit volume */
sl@0
   572
void TFatBootSector::SetFatSectors32(TUint32	aFatSectors32)
sl@0
   573
{iFatSectors32 = aFatSectors32;}
sl@0
   574
sl@0
   575
/** Sets the Fat flags */
sl@0
   576
void TFatBootSector::SetFATFlags(TUint16 aFATFlags)
sl@0
   577
{iFATFlags = aFATFlags;}
sl@0
   578
sl@0
   579
/** Sets the version number of the file system */
sl@0
   580
void TFatBootSector::SetVersionNumber(TUint16 aVersionNumber)
sl@0
   581
{iVersionNumber = aVersionNumber;}
sl@0
   582
sl@0
   583
/** Sets the cluster number of the root directory */
sl@0
   584
void TFatBootSector::SetRootClusterNum(TUint32 aRootClusterNum)	
sl@0
   585
{iRootClusterNum = aRootClusterNum;}
sl@0
   586
sl@0
   587
/** Set the sector number containing the FSIInfo structure */
sl@0
   588
void TFatBootSector::SetFSInfoSectorNum(TUint16 aFSInfoSectorNum)
sl@0
   589
{iFSInfoSectorNum = aFSInfoSectorNum;}
sl@0
   590
sl@0
   591
/** Set the backup boot sector */
sl@0
   592
void TFatBootSector::SetBkBootRecSector(TUint16 aBkBootRecSector)
sl@0
   593
{iBkBootRecSector = aBkBootRecSector;}	
sl@0
   594
sl@0
   595
/** Returns the vendor ID of the file system that formatted the volume */
sl@0
   596
const TPtrC8 TFatBootSector::VendorId() const
sl@0
   597
{return TPtrC8(iVendorId,KVendorIdSize);}
sl@0
   598
sl@0
   599
/** Return the bytes per sector */
sl@0
   600
TUint16 TFatBootSector::BytesPerSector() const
sl@0
   601
{return iBytesPerSector;}
sl@0
   602
sl@0
   603
/** Returns the sectors per cluster ratio */
sl@0
   604
TInt TFatBootSector::SectorsPerCluster() const
sl@0
   605
{return iSectorsPerCluster;}
sl@0
   606
sl@0
   607
/** Returns the number of reserved sectors on the volume */
sl@0
   608
TInt TFatBootSector::ReservedSectors() const
sl@0
   609
{return iReservedSectors;}
sl@0
   610
sl@0
   611
/** Returns the number of Fats on the volume */
sl@0
   612
TInt TFatBootSector::NumberOfFats() const
sl@0
   613
{return iNumberOfFats;}
sl@0
   614
sl@0
   615
/** Returns the number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32 */
sl@0
   616
TInt TFatBootSector::RootDirEntries() const
sl@0
   617
{return iRootDirEntries;}
sl@0
   618
sl@0
   619
/** Returns the total sectors on the volume, zero for FAT32 */
sl@0
   620
TInt TFatBootSector::TotalSectors() const
sl@0
   621
{return iTotalSectors;}
sl@0
   622
sl@0
   623
/** Returns the media descriptor */
sl@0
   624
TUint8 TFatBootSector::MediaDescriptor() const
sl@0
   625
{return iMediaDescriptor;}
sl@0
   626
sl@0
   627
/** Returns sectors used for the Fat table, zero for FAT32 */
sl@0
   628
TInt TFatBootSector::FatSectors() const
sl@0
   629
{return iFatSectors;}
sl@0
   630
sl@0
   631
/** Returns sectors per track */
sl@0
   632
TInt TFatBootSector::SectorsPerTrack() const
sl@0
   633
{return iSectorsPerTrack;}
sl@0
   634
sl@0
   635
/** Returns the number of heads  */
sl@0
   636
TInt TFatBootSector::NumberOfHeads() const
sl@0
   637
{return iNumberOfHeads;}
sl@0
   638
sl@0
   639
/** Returns the number of hidden sectors in the volume */
sl@0
   640
TInt TFatBootSector::HiddenSectors() const
sl@0
   641
{return iHiddenSectors;}
sl@0
   642
sl@0
   643
/** Returns total sectors in the volume, Used if totalSectors > 65535 */
sl@0
   644
TInt TFatBootSector::HugeSectors() const
sl@0
   645
{return iHugeSectors;}
sl@0
   646
sl@0
   647
/** Returns the physical drive number, not used in Symbian OS */
sl@0
   648
TInt TFatBootSector::PhysicalDriveNumber() const
sl@0
   649
{return iPhysicalDriveNumber;}
sl@0
   650
sl@0
   651
/** Returns the extended boot signiture */
sl@0
   652
TInt TFatBootSector::ExtendedBootSignature() const
sl@0
   653
{return iExtendedBootSignature;}
sl@0
   654
sl@0
   655
/** Returns the unique volume ID */
sl@0
   656
TUint32 TFatBootSector::UniqueID() const
sl@0
   657
{return iUniqueID;}
sl@0
   658
sl@0
   659
/** Returns the volume's label */
sl@0
   660
const TPtrC8 TFatBootSector::VolumeLabel() const
sl@0
   661
{return TPtrC8(iVolumeLabel,KVolumeLabelSize);}
sl@0
   662
sl@0
   663
/** Returns the file system type */
sl@0
   664
const TPtrC8 TFatBootSector::FileSysType() const
sl@0
   665
{return TPtrC8(iFileSysType,KFileSysTypeSize);}
sl@0
   666
sl@0
   667
/** Returns the boot sector signiture */
sl@0
   668
TInt TFatBootSector::BootSectorSignature() const
sl@0
   669
{return KBootSectorSignature;}
sl@0
   670
sl@0
   671
/** Set the jump instruction  */
sl@0
   672
void TFatBootSector::SetJumpInstruction()
sl@0
   673
{iJumpInstruction[0]=0xE9;iJumpInstruction[2]=0x90;}
sl@0
   674
sl@0
   675
/** Set the vendor ID of the file system that formatted the volume */
sl@0
   676
void TFatBootSector::SetVendorID(const TDesC8& aDes)
sl@0
   677
{
sl@0
   678
	ASSERT(aDes.Length()<=KVendorIdSize);
sl@0
   679
	TPtr8 buf(iVendorId,KVendorIdSize);
sl@0
   680
	buf=aDes;
sl@0
   681
}
sl@0
   682
sl@0
   683
/** Sets the bytes per sector  */
sl@0
   684
void TFatBootSector::SetBytesPerSector(TInt aBytesPerSector)
sl@0
   685
{
sl@0
   686
	ASSERT(!(aBytesPerSector&~KMaxTUint16));
sl@0
   687
	iBytesPerSector=(TUint16)aBytesPerSector;
sl@0
   688
}
sl@0
   689
sl@0
   690
/** Set the sectors per cluster ratio */
sl@0
   691
void TFatBootSector::SetSectorsPerCluster(TInt aSectorsPerCluster)
sl@0
   692
{
sl@0
   693
	ASSERT(!(aSectorsPerCluster&~KMaxTUint8));
sl@0
   694
	iSectorsPerCluster=(TUint8)aSectorsPerCluster;
sl@0
   695
}
sl@0
   696
sl@0
   697
sl@0
   698
/** Sets the number of reserved sectors on the volume */
sl@0
   699
void TFatBootSector::SetReservedSectors(TInt aReservedSectors)
sl@0
   700
{
sl@0
   701
	ASSERT(!(aReservedSectors&~KMaxTUint16));
sl@0
   702
	iReservedSectors=(TUint16)aReservedSectors;
sl@0
   703
}
sl@0
   704
sl@0
   705
/** Sets the number of Fats on the volume */
sl@0
   706
void TFatBootSector::SetNumberOfFats(TInt aNumberOfFats)
sl@0
   707
{
sl@0
   708
	ASSERT(!(aNumberOfFats&~KMaxTUint8));
sl@0
   709
	iNumberOfFats=(TUint8)aNumberOfFats;
sl@0
   710
}
sl@0
   711
sl@0
   712
/** Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32 */
sl@0
   713
void TFatBootSector::SetRootDirEntries(TInt aRootDirEntries)
sl@0
   714
{
sl@0
   715
	ASSERT(!(aRootDirEntries&~KMaxTUint16));
sl@0
   716
	iRootDirEntries=(TUint16)aRootDirEntries;
sl@0
   717
}
sl@0
   718
sl@0
   719
/** Total sectors on the volume, zero for FAT32 */
sl@0
   720
void TFatBootSector::SetTotalSectors(TInt aTotalSectors)
sl@0
   721
{
sl@0
   722
	ASSERT(!(aTotalSectors&~KMaxTUint16));
sl@0
   723
	iTotalSectors=(TUint16)aTotalSectors;
sl@0
   724
}
sl@0
   725
sl@0
   726
/** Set the media descriptor */
sl@0
   727
void TFatBootSector::SetMediaDescriptor(TUint8 aMediaDescriptor)
sl@0
   728
{iMediaDescriptor=aMediaDescriptor;}
sl@0
   729
sl@0
   730
/** Sectors used for the Fat table, zero for FAT32 */
sl@0
   731
void TFatBootSector::SetFatSectors(TInt aFatSectors)
sl@0
   732
{
sl@0
   733
	ASSERT(!(aFatSectors&~KMaxTUint16));
sl@0
   734
	iFatSectors=(TUint16)aFatSectors;
sl@0
   735
}
sl@0
   736
sl@0
   737
/** Set the sectors per track */
sl@0
   738
void TFatBootSector::SetSectorsPerTrack(TInt aSectorsPerTrack)
sl@0
   739
{
sl@0
   740
	ASSERT(!(aSectorsPerTrack&~KMaxTUint16));
sl@0
   741
	iSectorsPerTrack=(TUint16)aSectorsPerTrack;
sl@0
   742
}
sl@0
   743
sl@0
   744
/** Set the number of heads */
sl@0
   745
void TFatBootSector::SetNumberOfHeads(TInt aNumberOfHeads)
sl@0
   746
{
sl@0
   747
	ASSERT(!(aNumberOfHeads&~KMaxTUint16));
sl@0
   748
	iNumberOfHeads=(TUint16)aNumberOfHeads;
sl@0
   749
}
sl@0
   750
sl@0
   751
/** Set the number of hidden sectors in the volume */
sl@0
   752
void TFatBootSector::SetHiddenSectors(TUint32 aHiddenSectors)
sl@0
   753
{
sl@0
   754
	iHiddenSectors=(TUint32)(aHiddenSectors);
sl@0
   755
}
sl@0
   756
sl@0
   757
/** Set the total sectors in the volume, Used if totalSectors > 65535 */
sl@0
   758
void TFatBootSector::SetHugeSectors(TUint32 aHugeSectors)
sl@0
   759
{iHugeSectors=aHugeSectors;}
sl@0
   760
sl@0
   761
sl@0
   762
/** Physical drive number, not used in Symbian OS */
sl@0
   763
void TFatBootSector::SetPhysicalDriveNumber(TInt aPhysicalDriveNumber)
sl@0
   764
{
sl@0
   765
	ASSERT(!(aPhysicalDriveNumber&~KMaxTUint8));
sl@0
   766
	iPhysicalDriveNumber=(TUint8)aPhysicalDriveNumber;
sl@0
   767
}
sl@0
   768
sl@0
   769
/** Set the reserved byte value */
sl@0
   770
void TFatBootSector::SetReservedByte(TUint8 aReservedByte)
sl@0
   771
{iReserved=aReservedByte;}
sl@0
   772
sl@0
   773
/** Set the extended boot signiture */
sl@0
   774
void TFatBootSector::SetExtendedBootSignature(TInt anExtendedBootSignature)
sl@0
   775
{
sl@0
   776
	ASSERT(!(anExtendedBootSignature&~KMaxTUint8));
sl@0
   777
	iExtendedBootSignature=(TUint8)anExtendedBootSignature;
sl@0
   778
}
sl@0
   779
sl@0
   780
/** Set the unique volume ID */
sl@0
   781
void TFatBootSector::SetUniqueID(TUint32 anUniqueID)
sl@0
   782
{iUniqueID=anUniqueID;}
sl@0
   783
sl@0
   784
/** Set the volume's label */
sl@0
   785
void TFatBootSector::SetVolumeLabel(const TDesC8& aDes)
sl@0
   786
{
sl@0
   787
	ASSERT(aDes.Length()<=KVolumeLabelSize);
sl@0
   788
	TPtr8 buf(iVolumeLabel,KVolumeLabelSize);
sl@0
   789
	buf=aDes;
sl@0
   790
}
sl@0
   791
sl@0
   792
/** Set the file system type */
sl@0
   793
void TFatBootSector::SetFileSysType(const TDesC8& aDes)
sl@0
   794
{
sl@0
   795
	ASSERT(aDes.Length()<=8);
sl@0
   796
	TPtr8 buf(iFileSysType,8);
sl@0
   797
	buf=aDes;
sl@0
   798
}
sl@0
   799
sl@0
   800
sl@0
   801
/** @return The first Fat sector number */
sl@0
   802
TInt TFatBootSector::FirstFatSector() const
sl@0
   803
{
sl@0
   804
    __ASSERT_ALWAYS(IsValid(), User::Invariant());
sl@0
   805
    return ReservedSectors();
sl@0
   806
}
sl@0
   807
sl@0
   808
/**
sl@0
   809
    @return Number of sectors in root directory. 0 for FAT32
sl@0
   810
*/
sl@0
   811
TUint32 TFatBootSector::RootDirSectors() const
sl@0
   812
{
sl@0
   813
    __ASSERT_ALWAYS(IsValid(), User::Invariant());
sl@0
   814
    return ( (RootDirEntries()*KSizeOfFatDirEntry + (BytesPerSector()-1)) / BytesPerSector() );
sl@0
   815
}
sl@0
   816
sl@0
   817
sl@0
   818
/** @return Start sector number of the root directory */
sl@0
   819
TInt TFatBootSector::RootDirStartSector()  const
sl@0
   820
{
sl@0
   821
    __ASSERT_ALWAYS(IsValid(), User::Invariant());
sl@0
   822
    
sl@0
   823
    const TUint32 firstNonFatSec = ReservedSectors() + TotalFatSectors()*NumberOfFats();
sl@0
   824
sl@0
   825
    if(FatType() == EFat32)
sl@0
   826
    {//-- FAT32 root dir is a file, calculate the position by it's 1st cluster number. FAT[0]+FAT[1] are reserved.
sl@0
   827
        return (firstNonFatSec + (RootClusterNum()-KFatFirstSearchCluser) * SectorsPerCluster());
sl@0
   828
    }
sl@0
   829
    else
sl@0
   830
    {//-- FAT12/16 root dir starts just after the FATs
sl@0
   831
        return firstNonFatSec;
sl@0
   832
    }
sl@0
   833
sl@0
   834
}
sl@0
   835
sl@0
   836
/** @return first data sector number. for FAT32 it includes the root directory */
sl@0
   837
TInt TFatBootSector::FirstDataSector() const
sl@0
   838
{
sl@0
   839
    return( ReservedSectors() + NumberOfFats()*TotalFatSectors() + RootDirSectors() );
sl@0
   840
}
sl@0
   841
sl@0
   842
/** @return FAT-type independent sector count on the volume */
sl@0
   843
TUint32 TFatBootSector::VolumeTotalSectorNumber() const
sl@0
   844
{
sl@0
   845
    __ASSERT_ALWAYS(IsValid(), User::Invariant());
sl@0
   846
    return HugeSectors() ? (TUint32)HugeSectors() : (TUint32)TotalSectors();
sl@0
   847
}
sl@0
   848
sl@0
   849
/** @return FAT-type independent number of sectors in one FAT */
sl@0
   850
TUint32 TFatBootSector::TotalFatSectors() const
sl@0
   851
{
sl@0
   852
    __ASSERT_ALWAYS(IsValid(), User::Invariant());
sl@0
   853
    return FatSectors32() ? FatSectors32() : (TUint32)FatSectors();
sl@0
   854
}
sl@0
   855
sl@0
   856
sl@0
   857
//-------------------------------------------------------------------------------------------------------------------
sl@0
   858
sl@0
   859
sl@0
   860
const TUint32   KLeadSignature      = 0x41615252; ///< FSInfo Lead signiture value
sl@0
   861
const TUint32   KStructureSignature = 0x61417272; ///< FSInfo Structure signiture value
sl@0
   862
const TUint32   KTrailingSignature  = 0xAA550000; ///< FSInfo Trailing signiture
sl@0
   863
sl@0
   864
TFSInfo::TFSInfo()
sl@0
   865
{
sl@0
   866
    Initialise();
sl@0
   867
}
sl@0
   868
//-------------------------------------------------------------------------------------------------------------------
sl@0
   869
sl@0
   870
/** Initialise the data */
sl@0
   871
void TFSInfo::Initialise()  
sl@0
   872
{
sl@0
   873
    Mem::FillZ(this, sizeof(TFSInfo));
sl@0
   874
sl@0
   875
    iLeadSig      = KLeadSignature; 
sl@0
   876
    iStructureSig = KStructureSignature;
sl@0
   877
    iTrainlingSig = KTrailingSignature;
sl@0
   878
}
sl@0
   879
sl@0
   880
sl@0
   881
TBool TFSInfo::operator==(const TFSInfo& aRhs)
sl@0
   882
{
sl@0
   883
    ASSERT(&aRhs != this);
sl@0
   884
    if(&aRhs == this)
sl@0
   885
        return ETrue; //-- comparing with itself
sl@0
   886
sl@0
   887
    return  (Mem::Compare((TUint8*)this, sizeof(TFSInfo), (TUint8*)&aRhs, sizeof(TFSInfo)) == 0);
sl@0
   888
}
sl@0
   889
sl@0
   890
//-------------------------------------------------------------------------------------------------------------------
sl@0
   891
sl@0
   892
/**
sl@0
   893
    @return ETrue if FSInfo sector contents seems to be valid
sl@0
   894
*/
sl@0
   895
TBool TFSInfo::IsValid() const
sl@0
   896
{
sl@0
   897
    return (iLeadSig == KLeadSignature && iStructureSig == KStructureSignature && iTrainlingSig == KTrailingSignature);
sl@0
   898
}
sl@0
   899
sl@0
   900
//-------------------------------------------------------------------------------------------------------------------
sl@0
   901
sl@0
   902
/**
sl@0
   903
    Initialize FSInfo sector object from the given bufer. Does not validate the data.
sl@0
   904
    @param  aBuf buffer with data.
sl@0
   905
*/
sl@0
   906
void TFSInfo::Internalize(const TDesC8& aBuf)
sl@0
   907
{
sl@0
   908
    ASSERT((TUint32)aBuf.Size() >= KSizeOfFSInfo);
sl@0
   909
sl@0
   910
    TInt pos=0;
sl@0
   911
sl@0
   912
    Mem::Copy(&iLeadSig, &aBuf[pos],4);      pos+=(KFSInfoReserved1Size+4);
sl@0
   913
    Mem::Copy(&iStructureSig, &aBuf[pos],4); pos+=4;
sl@0
   914
    Mem::Copy(&iFreeCount,&aBuf[pos],4);     pos+=4;
sl@0
   915
    Mem::Copy(&iNextFree,&aBuf[pos],4);      pos+=(4+KFSInfoReserved2Size);
sl@0
   916
    Mem::Copy(&iTrainlingSig,&aBuf[pos],4);
sl@0
   917
}
sl@0
   918
sl@0
   919
//-------------------------------------------------------------------------------------------------------------------
sl@0
   920
sl@0
   921
/**
sl@0
   922
    Externalize FSInfo sector object to the given data buffer.
sl@0
   923
    @param  aBuf buffer to externalize.
sl@0
   924
*/
sl@0
   925
void TFSInfo::Externalize(TDes8& aBuf) const
sl@0
   926
{
sl@0
   927
    ASSERT((TUint32)aBuf.MaxSize() >= KSizeOfFSInfo);
sl@0
   928
    
sl@0
   929
    aBuf.SetLength(KSizeOfFSInfo);
sl@0
   930
    aBuf.FillZ();
sl@0
   931
    
sl@0
   932
    TInt pos=0;
sl@0
   933
sl@0
   934
    Mem::Copy(&aBuf[pos],&KLeadSignature,4);        pos+=4; 
sl@0
   935
                                                    pos+=KFSInfoReserved1Size;
sl@0
   936
    Mem::Copy(&aBuf[pos],&KStructureSignature,4);   pos+=4;
sl@0
   937
    Mem::Copy(&aBuf[pos],&iFreeCount,4);            pos+=4;
sl@0
   938
    Mem::Copy(&aBuf[pos],&iNextFree,4);             pos+=4;
sl@0
   939
                                                    pos+=KFSInfoReserved2Size;
sl@0
   940
    Mem::Copy(&aBuf[pos],&KTrailingSignature,4);
sl@0
   941
}
sl@0
   942
sl@0
   943
//-------------------------------------------------------------------------------------------------------------------
sl@0
   944
sl@0
   945
/** 
sl@0
   946
    Print out the FSInfo sector info.
sl@0
   947
*/
sl@0
   948
void TFSInfo::PrintDebugInfo() const
sl@0
   949
{
sl@0
   950
    DoPrintf(_L("==== FSInfoSector : ====\n"));
sl@0
   951
    DoPrintf(_L("FSI_LeadSig:   0x%x\n"),iLeadSig);
sl@0
   952
    DoPrintf(_L("FSI_StrucSig:  0x%x\n"),iStructureSig);
sl@0
   953
    DoPrintf(_L("FSI_FreeCount: 0x%x\n"),iFreeCount);
sl@0
   954
    DoPrintf(_L("FSI_NxtFree:   0x%x\n"),iNextFree);
sl@0
   955
    DoPrintf(_L("FSI_TrailSig:  0x%x\n"),iTrainlingSig);
sl@0
   956
    DoPrintf(_L("========================\n"));
sl@0
   957
}
sl@0
   958
sl@0
   959
TUint32 TFSInfo::FreeClusterCount() const 
sl@0
   960
{
sl@0
   961
    return iFreeCount;
sl@0
   962
}
sl@0
   963
sl@0
   964
TUint32 TFSInfo::NextFreeCluster() const
sl@0
   965
{
sl@0
   966
    return iNextFree;
sl@0
   967
}
sl@0
   968
sl@0
   969
sl@0
   970
void TFSInfo::SetFreeClusterCount(TUint32 aFreeCount)
sl@0
   971
{
sl@0
   972
    iFreeCount = aFreeCount;
sl@0
   973
}
sl@0
   974
sl@0
   975
void TFSInfo::SetNextFreeCluster(TUint32 aNextCluster)
sl@0
   976
{
sl@0
   977
    iNextFree = aNextCluster;
sl@0
   978
}
sl@0
   979
sl@0
   980
sl@0
   981
//-------------------------------------------------------------------------------------------------------------------
sl@0
   982
sl@0
   983
/**
sl@0
   984
    Deciphers the dos time/date entry information and converts to TTime
sl@0
   985
*/
sl@0
   986
TTime Fat_Test_Utils::DosTimeToTTime(TInt aDosTime,TInt aDosDate)
sl@0
   987
	{
sl@0
   988
	TInt secMask=0x1F;
sl@0
   989
	TInt minMask=0x07E0;
sl@0
   990
	TInt hrMask=0xF800;
sl@0
   991
	TInt dayMask=0x1F;
sl@0
   992
	TInt monthMask=0x01E0;
sl@0
   993
	TInt yearMask=0xFE00;
sl@0
   994
sl@0
   995
	TInt secs=(aDosTime&secMask)*2;
sl@0
   996
	TInt mins=(aDosTime&minMask)>>5;
sl@0
   997
	TInt hrs=(aDosTime&hrMask)>>11;
sl@0
   998
	TInt days=(aDosDate&dayMask)-1;
sl@0
   999
	TMonth months=(TMonth)(((aDosDate&monthMask)>>5)-1);
sl@0
  1000
	TInt years=((aDosDate&yearMask)>>9)+1980;
sl@0
  1001
	
sl@0
  1002
	TDateTime datetime;
sl@0
  1003
	TInt ret=datetime.Set(years,months,days,hrs,mins,secs,0);
sl@0
  1004
	if (ret==KErrNone)
sl@0
  1005
		return(TTime(datetime));
sl@0
  1006
	return(TTime(0));
sl@0
  1007
	}
sl@0
  1008
sl@0
  1009
/**
sl@0
  1010
Converts a TTime to a dos time
sl@0
  1011
*/
sl@0
  1012
TInt Fat_Test_Utils::DosTimeFromTTime(const TTime& aTime)
sl@0
  1013
	{
sl@0
  1014
	TDateTime dateTime=aTime.DateTime();
sl@0
  1015
	TInt dosSecs=dateTime.Second()/2;
sl@0
  1016
	TInt dosMins=dateTime.Minute()<<5;
sl@0
  1017
	TInt dosHrs=dateTime.Hour()<<11;
sl@0
  1018
	return dosSecs|dosMins|dosHrs;
sl@0
  1019
	}
sl@0
  1020
sl@0
  1021
/**
sl@0
  1022
Converts a TTime to a dos date
sl@0
  1023
*/
sl@0
  1024
TInt Fat_Test_Utils::DosDateFromTTime(const TTime& aTime)
sl@0
  1025
	{
sl@0
  1026
sl@0
  1027
	TDateTime dateTime=aTime.DateTime();
sl@0
  1028
	TInt dosDays=dateTime.Day()+1;
sl@0
  1029
	TInt dosMonths=(dateTime.Month()+1)<<5;
sl@0
  1030
	TInt dosYears=(dateTime.Year()-1980)<<9;
sl@0
  1031
	return dosDays|dosMonths|dosYears;
sl@0
  1032
	}
sl@0
  1033
sl@0
  1034
sl@0
  1035
/**
sl@0
  1036
Converts xxx.yyy to standard format aaaaaaaayyy
sl@0
  1037
*/
sl@0
  1038
TBuf8<12> Fat_Test_Utils::DosNameToStdFormat(const TDesC8& aDosName)
sl@0
  1039
	{
sl@0
  1040
    ASSERT(aDosName.Length()>=0 && aDosName.Length()<=KMaxFatFileName);
sl@0
  1041
sl@0
  1042
	TBuf8<12> result;
sl@0
  1043
	Mem::Fill((TUint8*)result.Ptr(),result.MaxSize(),' ');
sl@0
  1044
	TInt dotPos=aDosName.Locate('.');
sl@0
  1045
	if (dotPos==KErrNotFound)
sl@0
  1046
		{
sl@0
  1047
		result=aDosName;
sl@0
  1048
		result.SetLength(11);
sl@0
  1049
		return result;
sl@0
  1050
		}
sl@0
  1051
	result=aDosName.Left(dotPos);
sl@0
  1052
	result.SetLength(11);
sl@0
  1053
	TPtr8 ext(&result[8],3);
sl@0
  1054
	ext=aDosName.Right(aDosName.Length()-dotPos-1);
sl@0
  1055
	return result;
sl@0
  1056
	}
sl@0
  1057
sl@0
  1058
/**
sl@0
  1059
Converts aaaaaaaayyy to dos name format xxx.yyy
sl@0
  1060
*/
sl@0
  1061
TBuf8<12> Fat_Test_Utils::DosNameFromStdFormat(const TDesC8& aStdFormatName)
sl@0
  1062
	{
sl@0
  1063
    ASSERT(aStdFormatName.Length()==11);
sl@0
  1064
sl@0
  1065
	TBuf8<12> result;
sl@0
  1066
	TInt nameLen=aStdFormatName.Locate(' ');
sl@0
  1067
	if (nameLen>8 || nameLen==KErrNotFound)
sl@0
  1068
		nameLen=8;
sl@0
  1069
	result=aStdFormatName.Left(nameLen);
sl@0
  1070
	TPtrC8 ext(&aStdFormatName[8],3);
sl@0
  1071
	TInt extLen=ext.Locate(' ');
sl@0
  1072
	if (extLen)
sl@0
  1073
		result.Append(TChar('.'));
sl@0
  1074
	if (extLen==KErrNotFound)
sl@0
  1075
		extLen=3;
sl@0
  1076
	result.Append(ext.Left(extLen));
sl@0
  1077
    if(result.Length() && result[0]==0x05 )
sl@0
  1078
	    {
sl@0
  1079
	    result[0]=0xE5;
sl@0
  1080
	    }
sl@0
  1081
	return result;
sl@0
  1082
	}
sl@0
  1083
sl@0
  1084
/**
sl@0
  1085
Return the number of VFat entries required to describe a filename of length aNameLength
sl@0
  1086
*/
sl@0
  1087
TInt Fat_Test_Utils::NumberOfVFatEntries(TInt aNameLength)
sl@0
  1088
	{
sl@0
  1089
	TInt numberOfEntries=0;
sl@0
  1090
	if (aNameLength%KMaxVFatEntryName)
sl@0
  1091
		aNameLength++;	//	Include a zero terminator
sl@0
  1092
//	If aNameLength is a exact multiple of KMaxVFatEntryName, don't bother
sl@0
  1093
//	with a zero terminator - it just adds an unnecessary directory entry		
sl@0
  1094
	
sl@0
  1095
	numberOfEntries=(1+(aNameLength/KMaxVFatEntryName));	
sl@0
  1096
	
sl@0
  1097
	if (aNameLength%KMaxVFatEntryName)
sl@0
  1098
		numberOfEntries++;
sl@0
  1099
	
sl@0
  1100
	return(numberOfEntries);
sl@0
  1101
	}
sl@0
  1102
sl@0
  1103
/**
sl@0
  1104
Calculate a checksum to tie the vFat and dos names together
sl@0
  1105
*/
sl@0
  1106
TUint8 Fat_Test_Utils::CalculateShortNameCheckSum(const TDesC8& aShortName)
sl@0
  1107
	{
sl@0
  1108
sl@0
  1109
	TUint8 cksum=0;
sl@0
  1110
	for (TInt i=0;i<11;i++)
sl@0
  1111
		cksum =(TUint8)((((cksum&1)<<7)|((cksum&0xfe)>>1))+aShortName[i]);
sl@0
  1112
sl@0
  1113
	return(cksum);
sl@0
  1114
	}
sl@0
  1115
sl@0
  1116
sl@0
  1117
//-------------------------------------------------------------------------------------------------------------------
sl@0
  1118
sl@0
  1119
sl@0
  1120
#define pDir ((SFatDirEntry*)&iData[0])
sl@0
  1121
const TUint8 KEntryErasedMarker=0xE5;
sl@0
  1122
sl@0
  1123
sl@0
  1124
TFatDirEntry::TFatDirEntry() 
sl@0
  1125
    {
sl@0
  1126
    InitZ();
sl@0
  1127
    }       
sl@0
  1128
sl@0
  1129
/** zero-fill the entry contents  */
sl@0
  1130
void TFatDirEntry::InitZ() 
sl@0
  1131
    {
sl@0
  1132
    Mem::FillZ(iData, KSizeOfFatDirEntry);
sl@0
  1133
    }
sl@0
  1134
sl@0
  1135
sl@0
  1136
/**
sl@0
  1137
@return  ETrue if the Directory entry contains garbage data
sl@0
  1138
*/
sl@0
  1139
TBool TFatDirEntry::IsGarbage() const
sl@0
  1140
    {
sl@0
  1141
    return (iData[0]==0xFF);
sl@0
  1142
    }
sl@0
  1143
sl@0
  1144
/**
sl@0
  1145
Return the Dos name of a directory entry
sl@0
  1146
@return A descriptor containing the Dos name of a directory entry
sl@0
  1147
*/
sl@0
  1148
const TPtrC8 TFatDirEntry::Name() const
sl@0
  1149
	{return TPtrC8((TUint8*)&(pDir->iName),KFatDirNameSize);}
sl@0
  1150
sl@0
  1151
/** @return The attributes for the Directory entry */
sl@0
  1152
TInt TFatDirEntry::Attributes() const
sl@0
  1153
	{return pDir->iAttributes;}
sl@0
  1154
sl@0
  1155
/** @return Time of file creation */
sl@0
  1156
TTime TFatDirEntry::Time() const
sl@0
  1157
	{return DosTimeToTTime(pDir->iTime,pDir->iDate);}
sl@0
  1158
sl@0
  1159
/** @return The Start cluster for the file or directory for this entry  */
sl@0
  1160
TInt TFatDirEntry::StartCluster() const		
sl@0
  1161
	{
sl@0
  1162
    const TUint16 KStClustMaskHi = 0x0FFF;	
sl@0
  1163
    return ((pDir->iStartClusterHi&KStClustMaskHi)<<16) | pDir->iStartClusterLo;
sl@0
  1164
    }
sl@0
  1165
sl@0
  1166
/** @return The size of file or directory for this entry  */
sl@0
  1167
TUint32 TFatDirEntry::Size() const
sl@0
  1168
	{return pDir->iSize;}
sl@0
  1169
sl@0
  1170
/** @return True if the entry is erased */
sl@0
  1171
TBool TFatDirEntry::IsErased() const
sl@0
  1172
	{return (TBool)(iData[0]==KEntryErasedMarker);}
sl@0
  1173
sl@0
  1174
/** @return True if the entry refers to the current directory */
sl@0
  1175
TBool TFatDirEntry::IsCurrentDirectory() const
sl@0
  1176
	{return (TBool)(iData[0]==KDotEntryByte && iData[1]==KBlankSpace);}
sl@0
  1177
sl@0
  1178
/** @return True if the Entry refers to the parent directory */
sl@0
  1179
TBool TFatDirEntry::IsParentDirectory() const
sl@0
  1180
	{return (TBool)(iData[0]==KDotEntryByte && iData[1]==KDotEntryByte);}
sl@0
  1181
sl@0
  1182
/** @return True if end of directory */
sl@0
  1183
TBool TFatDirEntry::IsEndOfDirectory() const
sl@0
  1184
	{return (TBool)(iData[0]==0x00);}
sl@0
  1185
sl@0
  1186
/** 
sl@0
  1187
Set the Dos name of a directory entry 
sl@0
  1188
@param aDes A descriptor containg the name
sl@0
  1189
*/
sl@0
  1190
void TFatDirEntry::SetName(const TDesC8& aDes)
sl@0
  1191
	{
sl@0
  1192
    ASSERT(aDes.Length()<=KFatDirNameSize);
sl@0
  1193
	TPtr8 name(pDir->iName,KFatDirNameSize);
sl@0
  1194
	name=aDes;
sl@0
  1195
	}
sl@0
  1196
sl@0
  1197
/** 
sl@0
  1198
Set the file or directory attributes for this entry 
sl@0
  1199
@param anAtts The file or directory attributes
sl@0
  1200
*/
sl@0
  1201
void TFatDirEntry::SetAttributes(TInt anAtts)
sl@0
  1202
	{
sl@0
  1203
	ASSERT(!(anAtts&~KMaxTUint8));
sl@0
  1204
	pDir->iAttributes=(TUint8)anAtts;
sl@0
  1205
	}
sl@0
  1206
sl@0
  1207
/**
sl@0
  1208
Set the creation time and data of the directory entry
sl@0
  1209
@param aTime Creation time of the file or directory
sl@0
  1210
*/
sl@0
  1211
void TFatDirEntry::SetTime(TTime aTime)
sl@0
  1212
	{
sl@0
  1213
	pDir->iTime=(TUint16)DosTimeFromTTime(aTime);
sl@0
  1214
	pDir->iDate=(TUint16)DosDateFromTTime(aTime);
sl@0
  1215
	}
sl@0
  1216
sl@0
  1217
void TFatDirEntry::SetCreateTime(TTime aTime)
sl@0
  1218
	{
sl@0
  1219
	pDir->iTimeC=(TUint16)DosTimeFromTTime(aTime);
sl@0
  1220
	pDir->iDateC=(TUint16)DosDateFromTTime(aTime);
sl@0
  1221
	}
sl@0
  1222
sl@0
  1223
/**
sl@0
  1224
Set the start cluster number of the file or directory refered to by the entry
sl@0
  1225
@param aStartCluster The start cluster number
sl@0
  1226
*/
sl@0
  1227
void TFatDirEntry::SetStartCluster(TInt aStartCluster)
sl@0
  1228
	{
sl@0
  1229
	const TUint32 KHalfWordMask	= 0x0000FFFF;
sl@0
  1230
    pDir->iStartClusterLo=(TUint16)(aStartCluster & KHalfWordMask);
sl@0
  1231
	pDir->iStartClusterHi=(TUint16)((aStartCluster>>16) & KHalfWordMask);
sl@0
  1232
	}
sl@0
  1233
sl@0
  1234
/**
sl@0
  1235
Set the size of the file or directory refered to by the entry
sl@0
  1236
@param aFileSize Size of the file
sl@0
  1237
*/
sl@0
  1238
void TFatDirEntry::SetSize(TUint32 aFileSize)
sl@0
  1239
	{pDir->iSize=aFileSize;}
sl@0
  1240
sl@0
  1241
/** Set the directory entry as erased */
sl@0
  1242
void TFatDirEntry::SetErased()
sl@0
  1243
	{iData[0]=KEntryErasedMarker;}
sl@0
  1244
sl@0
  1245
/**  Set the current entry to refer to the current directory */
sl@0
  1246
void TFatDirEntry::SetCurrentDirectory()
sl@0
  1247
	{
sl@0
  1248
	iData[0]='.';
sl@0
  1249
	Mem::Fill(&iData[1],KFatDirNameSize-1,' ');
sl@0
  1250
	}
sl@0
  1251
sl@0
  1252
/** Set the current entry to refer to the parent directory */
sl@0
  1253
void TFatDirEntry::SetParentDirectory()
sl@0
  1254
	{
sl@0
  1255
	iData[0]='.';iData[1]='.';
sl@0
  1256
	Mem::Fill(&iData[2],KFatDirNameSize-2,' ');
sl@0
  1257
	}
sl@0
  1258
sl@0
  1259
/** Set the current entry to be the end of directory marker */
sl@0
  1260
void TFatDirEntry::SetEndOfDirectory()
sl@0
  1261
	{Mem::FillZ(&iData[0],KFatDirNameSize);}
sl@0
  1262
sl@0
  1263
/**  @return True if the entry is the start of a long name set of entries */
sl@0
  1264
TBool TFatDirEntry::IsLongNameStart() const
sl@0
  1265
	{return (TBool)((iData[0]&0x40) != 0);}
sl@0
  1266
sl@0
  1267
/** @return True is the Entry is a VFat entry  */
sl@0
  1268
TBool TFatDirEntry::IsVFatEntry() const
sl@0
  1269
	{return (TBool)(Attributes()==KVFatEntryAttribute && IsEndOfDirectory()==EFalse);}
sl@0
  1270
sl@0
  1271
/** @return The number of following VFat entries */
sl@0
  1272
TInt TFatDirEntry::NumFollowing() const
sl@0
  1273
	{return (iData[0]&0x3F);}
sl@0
  1274
sl@0
  1275
sl@0
  1276
TUint8 TFatDirEntry::CheckSum() const
sl@0
  1277
    {
sl@0
  1278
        ASSERT(IsVFatEntry());
sl@0
  1279
        return iData[13];
sl@0
  1280
    }
sl@0
  1281
sl@0
  1282
sl@0
  1283
sl@0
  1284
sl@0
  1285
sl@0
  1286
sl@0
  1287
sl@0
  1288
sl@0
  1289
sl@0
  1290
sl@0
  1291
sl@0
  1292
sl@0
  1293
sl@0
  1294
sl@0
  1295
sl@0
  1296
sl@0
  1297
sl@0
  1298
sl@0
  1299
sl@0
  1300
sl@0
  1301