|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // @file |
|
15 // various FAT utilities header file |
|
16 // |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #ifndef F32_TEST_UTILS_HEADER |
|
22 #define F32_TEST_UTILS_HEADER |
|
23 |
|
24 #include <f32fsys.h> |
|
25 |
|
26 namespace F32_Test_Utils |
|
27 { |
|
28 |
|
29 const TUint32 K1KiloByte = 1<<10; |
|
30 const TUint32 K1MegaByte = 1<<20; |
|
31 const TUint32 K1GigaByte = 1<<30; |
|
32 |
|
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 |
|
36 |
|
37 //----------------------------------------------------------------------------- |
|
38 |
|
39 void SetConsole(CConsoleBase* apConsole); |
|
40 |
|
41 TBool EnablePrintOutput(TBool bEnable); |
|
42 |
|
43 |
|
44 //############################################################################# |
|
45 //# File System independent functions and classes |
|
46 //############################################################################# |
|
47 |
|
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); |
|
52 |
|
53 TInt CreateCheckableStuffedFile(RFs& aFs, const TDesC& aFileName, TUint64 aSize); |
|
54 TInt VerifyCheckableFile(RFs& aFs, const TDesC& aFileName); |
|
55 |
|
56 TInt CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint64 aSize); |
|
57 |
|
58 TInt RemountFS(RFs& aFs, TInt aDrive, TTime* apTimeMountStart=NULL); |
|
59 |
|
60 TInt FormatDrive(RFs &aFs, TInt aDrive, TBool aQuickFormat); |
|
61 |
|
62 |
|
63 //----------------------------------------------------------------------------- |
|
64 /** |
|
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 |
|
67 */ |
|
68 class TFSDescriptor |
|
69 { |
|
70 public: |
|
71 TFSDescriptor(); |
|
72 void Init(); |
|
73 |
|
74 TBool operator==(const TFSDescriptor& aRhs) const; |
|
75 |
|
76 public: |
|
77 |
|
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 |
|
81 |
|
82 }; |
|
83 |
|
84 TInt GetFileSystemDescriptor(RFs &aFs, TInt aDrive, TFSDescriptor& aFsDesc); |
|
85 TInt MountFileSystem(RFs &aFs, TInt aDrive, const TFSDescriptor& aFsDesc); |
|
86 |
|
87 //----------------------------------------------------------------------------- |
|
88 |
|
89 |
|
90 /** |
|
91 Indicates if a number passed in is a power of two |
|
92 @return ETrue if aVal is a power of 2 |
|
93 */ |
|
94 TBool IsPowerOf2(TUint32 aVal); |
|
95 |
|
96 /** |
|
97 Calculates the log2 of a number |
|
98 |
|
99 @param aNum Number to calulate the log two of |
|
100 @return The log two of the number passed in |
|
101 */ |
|
102 TUint32 Log2(TUint32 aVal); |
|
103 |
|
104 //----------------------------------------------------------------------------- |
|
105 |
|
106 /** |
|
107 This is normal implementation that unlike Symbian's doesn't have 2^32 max. bits message length limitation. |
|
108 */ |
|
109 class TMD5 |
|
110 { |
|
111 public: |
|
112 |
|
113 enum {HashSize = 16}; ///< MD5 hash size in bytes |
|
114 TMD5(); |
|
115 |
|
116 void Reset(); |
|
117 void Update(const TDesC8& aMessage); |
|
118 TPtrC8 Final(const TDesC8& aMessage); |
|
119 TPtrC8 Final(); |
|
120 |
|
121 private: |
|
122 |
|
123 void Md5_process(const TUint8 *data /*[64]*/); |
|
124 void Md5_finish(); |
|
125 void Md5_append(const TUint8 *data, TInt nbytes); |
|
126 |
|
127 struct TState |
|
128 { |
|
129 TUint32 count[2]; ///< message length in bits, lsw first |
|
130 TUint32 abcd[4]; ///< digest buffer |
|
131 TUint8 buf[64]; ///< accumulate block |
|
132 }; |
|
133 |
|
134 TState iState; |
|
135 TUint8 iDigest[HashSize]; |
|
136 }; |
|
137 |
|
138 |
|
139 |
|
140 |
|
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 |
|
145 |
|
146 |
|
147 TBool Is_Fat(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS (FAT12/16/32) is mounted on this drive |
|
148 |
|
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 |
|
152 |
|
153 |
|
154 |
|
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); |
|
161 |
|
162 |
|
163 |
|
164 }//F32_Test_Utils |
|
165 |
|
166 |
|
167 #endif //F32_TEST_UTILS_HEADER |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |