sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // @file sl@0: // various FAT utilities header file sl@0: // sl@0: // sl@0: sl@0: sl@0: sl@0: #ifndef F32_TEST_UTILS_HEADER sl@0: #define F32_TEST_UTILS_HEADER sl@0: sl@0: #include sl@0: sl@0: namespace F32_Test_Utils sl@0: { sl@0: sl@0: const TUint32 K1KiloByte = 1<<10; sl@0: const TUint32 K1MegaByte = 1<<20; sl@0: const TUint32 K1GigaByte = 1<<30; sl@0: sl@0: const TUint K1uSec = 1; ///< 1 misrosecond in TTimeIntervalMicroSeconds32 sl@0: const TUint K1mSec = 1000; ///< 1 millisecond in TTimeIntervalMicroSeconds32 sl@0: const TUint K1Sec = 1000*K1mSec; ///< 1 second in TTimeIntervalMicroSeconds32 sl@0: sl@0: //----------------------------------------------------------------------------- sl@0: sl@0: void SetConsole(CConsoleBase* apConsole); sl@0: sl@0: TBool EnablePrintOutput(TBool bEnable); sl@0: sl@0: sl@0: //############################################################################# sl@0: //# File System independent functions and classes sl@0: //############################################################################# sl@0: sl@0: TInt PrintDrvInfo(RFs &aFs, TInt aDrive); sl@0: TInt MediaRawRead(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TUint32 aLen, TDes8& aData); sl@0: TInt MediaRawWrite(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TDesC8& aData); sl@0: TInt FillMedia(RFs &aFs, TInt aDrive, TInt64 aMediaStartPos, TInt64 aMediaEndPos, TUint8 aBytePattern=0); sl@0: sl@0: TInt CreateCheckableStuffedFile(RFs& aFs, const TDesC& aFileName, TUint64 aSize); sl@0: TInt VerifyCheckableFile(RFs& aFs, const TDesC& aFileName); sl@0: sl@0: TInt CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint64 aSize); sl@0: sl@0: TInt RemountFS(RFs& aFs, TInt aDrive, TTime* apTimeMountStart=NULL); sl@0: sl@0: TInt FormatDrive(RFs &aFs, TInt aDrive, TBool aQuickFormat); sl@0: sl@0: sl@0: //----------------------------------------------------------------------------- sl@0: /** sl@0: a file system descriptor. Contains the information about file system. sl@0: support for non-primary FS extensions is not implemented yet, it suports primary extensions only sl@0: */ sl@0: class TFSDescriptor sl@0: { sl@0: public: sl@0: TFSDescriptor(); sl@0: void Init(); sl@0: sl@0: TBool operator==(const TFSDescriptor& aRhs) const; sl@0: sl@0: public: sl@0: sl@0: TBuf<32> iFsName; ///< file system name. sl@0: TBuf<32> iPExtName; ///< primary extension name if it is present. Length == 0 means that there is no primary extension sl@0: TBool iDriveSynch;///< ETrue if the drive is synchronous sl@0: sl@0: }; sl@0: sl@0: TInt GetFileSystemDescriptor(RFs &aFs, TInt aDrive, TFSDescriptor& aFsDesc); sl@0: TInt MountFileSystem(RFs &aFs, TInt aDrive, const TFSDescriptor& aFsDesc); sl@0: sl@0: //----------------------------------------------------------------------------- sl@0: sl@0: sl@0: /** sl@0: Indicates if a number passed in is a power of two sl@0: @return ETrue if aVal is a power of 2 sl@0: */ sl@0: TBool IsPowerOf2(TUint32 aVal); sl@0: sl@0: /** sl@0: Calculates the log2 of a number sl@0: sl@0: @param aNum Number to calulate the log two of sl@0: @return The log two of the number passed in sl@0: */ sl@0: TUint32 Log2(TUint32 aVal); sl@0: sl@0: //----------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: This is normal implementation that unlike Symbian's doesn't have 2^32 max. bits message length limitation. sl@0: */ sl@0: class TMD5 sl@0: { sl@0: public: sl@0: sl@0: enum {HashSize = 16}; ///< MD5 hash size in bytes sl@0: TMD5(); sl@0: sl@0: void Reset(); sl@0: void Update(const TDesC8& aMessage); sl@0: TPtrC8 Final(const TDesC8& aMessage); sl@0: TPtrC8 Final(); sl@0: sl@0: private: sl@0: sl@0: void Md5_process(const TUint8 *data /*[64]*/); sl@0: void Md5_finish(); sl@0: void Md5_append(const TUint8 *data, TInt nbytes); sl@0: sl@0: struct TState sl@0: { sl@0: TUint32 count[2]; ///< message length in bits, lsw first sl@0: TUint32 abcd[4]; ///< digest buffer sl@0: TUint8 buf[64]; ///< accumulate block sl@0: }; sl@0: sl@0: TState iState; sl@0: TUint8 iDigest[HashSize]; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: TBool Is_Lffs(RFs &aFs, TInt aDrive); //-- returns ETrue if "lffs" FS is mounted on this drive sl@0: 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:) sl@0: TBool Is_ExFat(RFs &aFs, TInt aDrive); //-- returns ETrue if "exFAT" FS is mounted on this drive sl@0: TBool Is_Automounter(RFs &aFs, TInt aDrive); //-- returns ETrue if "Automounter" FS is mounted on this drive sl@0: sl@0: sl@0: TBool Is_Fat(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS (FAT12/16/32) is mounted on this drive sl@0: sl@0: TBool Is_Fat32(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT32 type sl@0: TBool Is_Fat16(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT16 type sl@0: TBool Is_Fat12(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT12 type sl@0: sl@0: sl@0: sl@0: //############################################################################# sl@0: //# some private helper functions sl@0: //############################################################################# sl@0: void DoPrintf(TRefByValue aFmt,...); sl@0: void DoMediaRawReadL(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TUint32 aLen, TDes8& aData); sl@0: void DoMediaRawWriteL(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TDesC8& aData); sl@0: sl@0: sl@0: sl@0: }//F32_Test_Utils sl@0: sl@0: sl@0: #endif //F32_TEST_UTILS_HEADER sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: