First public contribution.
1 // Copyright (c) 1996-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.
15 // various FAT utilities header file
21 #ifndef F32_TEST_UTILS_HEADER
22 #define F32_TEST_UTILS_HEADER
26 namespace F32_Test_Utils
29 const TUint32 K1KiloByte = 1<<10;
30 const TUint32 K1MegaByte = 1<<20;
31 const TUint32 K1GigaByte = 1<<30;
33 const TUint K1uSec = 1; ///< 1 misrosecond in TTimeIntervalMicroSeconds32
34 const TUint K1mSec = 1000; ///< 1 millisecond in TTimeIntervalMicroSeconds32
35 const TUint K1Sec = 1000*K1mSec; ///< 1 second in TTimeIntervalMicroSeconds32
37 //-----------------------------------------------------------------------------
39 void SetConsole(CConsoleBase* apConsole);
41 TBool EnablePrintOutput(TBool bEnable);
44 //#############################################################################
45 //# File System independent functions and classes
46 //#############################################################################
48 TInt PrintDrvInfo(RFs &aFs, TInt aDrive);
49 TInt MediaRawRead(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TUint32 aLen, TDes8& aData);
50 TInt MediaRawWrite(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TDesC8& aData);
51 TInt FillMedia(RFs &aFs, TInt aDrive, TInt64 aMediaStartPos, TInt64 aMediaEndPos, TUint8 aBytePattern=0);
53 TInt CreateCheckableStuffedFile(RFs& aFs, const TDesC& aFileName, TUint64 aSize);
54 TInt VerifyCheckableFile(RFs& aFs, const TDesC& aFileName);
56 TInt CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint64 aSize);
58 TInt RemountFS(RFs& aFs, TInt aDrive, TTime* apTimeMountStart=NULL);
60 TInt FormatDrive(RFs &aFs, TInt aDrive, TBool aQuickFormat);
63 //-----------------------------------------------------------------------------
65 a file system descriptor. Contains the information about file system.
66 support for non-primary FS extensions is not implemented yet, it suports primary extensions only
74 TBool operator==(const TFSDescriptor& aRhs) const;
78 TBuf<32> iFsName; ///< file system name.
79 TBuf<32> iPExtName; ///< primary extension name if it is present. Length == 0 means that there is no primary extension
80 TBool iDriveSynch;///< ETrue if the drive is synchronous
84 TInt GetFileSystemDescriptor(RFs &aFs, TInt aDrive, TFSDescriptor& aFsDesc);
85 TInt MountFileSystem(RFs &aFs, TInt aDrive, const TFSDescriptor& aFsDesc);
87 //-----------------------------------------------------------------------------
91 Indicates if a number passed in is a power of two
92 @return ETrue if aVal is a power of 2
94 TBool IsPowerOf2(TUint32 aVal);
97 Calculates the log2 of a number
99 @param aNum Number to calulate the log two of
100 @return The log two of the number passed in
102 TUint32 Log2(TUint32 aVal);
104 //-----------------------------------------------------------------------------
107 This is normal implementation that unlike Symbian's doesn't have 2^32 max. bits message length limitation.
113 enum {HashSize = 16}; ///< MD5 hash size in bytes
117 void Update(const TDesC8& aMessage);
118 TPtrC8 Final(const TDesC8& aMessage);
123 void Md5_process(const TUint8 *data /*[64]*/);
125 void Md5_append(const TUint8 *data, TInt nbytes);
129 TUint32 count[2]; ///< message length in bits, lsw first
130 TUint32 abcd[4]; ///< digest buffer
131 TUint8 buf[64]; ///< accumulate block
135 TUint8 iDigest[HashSize];
141 TBool Is_Lffs(RFs &aFs, TInt aDrive); //-- returns ETrue if "lffs" FS is mounted on this drive
142 TBool Is_Win32(RFs &aFs, TInt aDrive); //-- returns ETrue if "win32" FS is mounted on this drive (i.e this is emulator's drive c:)
143 TBool Is_ExFat(RFs &aFs, TInt aDrive); //-- returns ETrue if "exFAT" FS is mounted on this drive
144 TBool Is_Automounter(RFs &aFs, TInt aDrive); //-- returns ETrue if "Automounter" FS is mounted on this drive
147 TBool Is_Fat(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS (FAT12/16/32) is mounted on this drive
149 TBool Is_Fat32(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT32 type
150 TBool Is_Fat16(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT16 type
151 TBool Is_Fat12(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT12 type
155 //#############################################################################
156 //# some private helper functions
157 //#############################################################################
158 void DoPrintf(TRefByValue<const TDesC> aFmt,...);
159 void DoMediaRawReadL(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TUint32 aLen, TDes8& aData);
160 void DoMediaRawWriteL(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TDesC8& aData);
167 #endif //F32_TEST_UTILS_HEADER