author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 256 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 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 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
//----------------------------------------------------------------------------- |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
TBool CompareBuffers(const TDesC8& aBuf1, const TDesC8& aBuf2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
65 |
TBool CompareBuffers(const TAny* apBuf1, TUint aBuf1Len, const TAny* apBuf2, TUint aBuf2Len); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
67 |
void HexDump(const TDesC8& aBuf); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
68 |
void HexDump(const TAny* apBuf, TUint aBufLen); |
0 | 69 |
|
70 |
//----------------------------------------------------------------------------- |
|
71 |
/** |
|
72 |
a file system descriptor. Contains the information about file system. |
|
73 |
support for non-primary FS extensions is not implemented yet, it suports primary extensions only |
|
74 |
*/ |
|
75 |
class TFSDescriptor |
|
76 |
{ |
|
77 |
public: |
|
78 |
TFSDescriptor(); |
|
79 |
void Init(); |
|
80 |
||
81 |
TBool operator==(const TFSDescriptor& aRhs) const; |
|
82 |
||
83 |
public: |
|
84 |
||
85 |
TBuf<32> iFsName; ///< file system name. |
|
86 |
TBuf<32> iPExtName; ///< primary extension name if it is present. Length == 0 means that there is no primary extension |
|
87 |
TBool iDriveSynch;///< ETrue if the drive is synchronous |
|
88 |
||
89 |
}; |
|
90 |
||
91 |
TInt GetFileSystemDescriptor(RFs &aFs, TInt aDrive, TFSDescriptor& aFsDesc); |
|
92 |
TInt MountFileSystem(RFs &aFs, TInt aDrive, const TFSDescriptor& aFsDesc); |
|
93 |
||
94 |
//----------------------------------------------------------------------------- |
|
95 |
||
96 |
||
97 |
/** |
|
98 |
Indicates if a number passed in is a power of two |
|
99 |
@return ETrue if aVal is a power of 2 |
|
100 |
*/ |
|
101 |
TBool IsPowerOf2(TUint32 aVal); |
|
102 |
||
103 |
/** |
|
104 |
Calculates the log2 of a number |
|
105 |
||
106 |
@param aNum Number to calulate the log two of |
|
107 |
@return The log two of the number passed in |
|
108 |
*/ |
|
109 |
TUint32 Log2(TUint32 aVal); |
|
110 |
||
111 |
//----------------------------------------------------------------------------- |
|
112 |
||
113 |
/** |
|
114 |
This is normal implementation that unlike Symbian's doesn't have 2^32 max. bits message length limitation. |
|
115 |
*/ |
|
116 |
class TMD5 |
|
117 |
{ |
|
118 |
public: |
|
119 |
||
120 |
enum {HashSize = 16}; ///< MD5 hash size in bytes |
|
121 |
TMD5(); |
|
122 |
||
123 |
void Reset(); |
|
124 |
void Update(const TDesC8& aMessage); |
|
125 |
TPtrC8 Final(const TDesC8& aMessage); |
|
126 |
TPtrC8 Final(); |
|
127 |
||
128 |
private: |
|
129 |
||
130 |
void Md5_process(const TUint8 *data /*[64]*/); |
|
131 |
void Md5_finish(); |
|
132 |
void Md5_append(const TUint8 *data, TInt nbytes); |
|
133 |
||
134 |
struct TState |
|
135 |
{ |
|
136 |
TUint32 count[2]; ///< message length in bits, lsw first |
|
137 |
TUint32 abcd[4]; ///< digest buffer |
|
138 |
TUint8 buf[64]; ///< accumulate block |
|
139 |
}; |
|
140 |
||
141 |
TState iState; |
|
142 |
TUint8 iDigest[HashSize]; |
|
143 |
}; |
|
144 |
||
145 |
||
146 |
||
147 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
TBool Is_Lffs(RFs &aFs, TInt aDrive); //-- returns ETrue if "lffs" FS is mounted on this drive |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
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:) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
TBool Is_ExFat(RFs &aFs, TInt aDrive); //-- returns ETrue if "exFAT" FS is mounted on this drive |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
TBool Is_Automounter(RFs &aFs, TInt aDrive); //-- returns ETrue if "Automounter" FS is mounted on this drive |
0 | 152 |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
TBool Is_HVFS(RFs &aFs, TInt aDrive); //-- returns ETrue if "HVFS" is mounted on this drive (i.e PlatSim's drive C:) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
154 |
TBool Is_SimulatedSystemDrive(RFs &aFs, TInt aDrive); //-- returns ETrue if "HVFS" or "Win32" FS is mounted on this drive |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
155 |
// (i.e drive C: of PlatSim or the emulator) |
0 | 156 |
|
157 |
TBool Is_Fat(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS (FAT12/16/32) is mounted on this drive |
|
158 |
||
159 |
TBool Is_Fat32(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT32 type |
|
160 |
TBool Is_Fat16(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT16 type |
|
161 |
TBool Is_Fat12(RFs &aFs, TInt aDrive); //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT12 type |
|
162 |
||
163 |
||
164 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
166 |
|
0 | 167 |
//############################################################################# |
168 |
//# some private helper functions |
|
169 |
//############################################################################# |
|
170 |
void DoPrintf(TRefByValue<const TDesC> aFmt,...); |
|
171 |
void DoMediaRawReadL(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TUint32 aLen, TDes8& aData); |
|
172 |
void DoMediaRawWriteL(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TDesC8& aData); |
|
173 |
||
174 |
||
175 |
||
176 |
}//F32_Test_Utils |
|
177 |
||
178 |
||
179 |
#endif //F32_TEST_UTILS_HEADER |
|
180 |
||
181 |
||
182 |
||
183 |
||
184 |
||
185 |
||
186 |
||
187 |
||
188 |
||
189 |
||
190 |
||
191 |
||
192 |
||
193 |
||
194 |
||
195 |
||
196 |
||
197 |
||
198 |
||
199 |
||
200 |
||
201 |
||
202 |
||
203 |
||
204 |
||
205 |
||
206 |
||
207 |
||
208 |
||
209 |
||
210 |
||
211 |
||
212 |
||
213 |